English 中文(简体)
页: 1
原标题:rename a file in javascript

i 想要问,如果想要将档案改名为javascript,那么我能做些什么? i 尝试一种功能,即在线查阅,但不能工作。

function ChangeFileName()
{
    var fso, f;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f = fso.GetFile("FilePath/MyFile.txt");
    f.name = "MyFile.htm";
} 

i 在线查询,它说,只有IE才能获得活性XObject,而且由于 mo虫有泡沫,它打算在 mo里使用。

beside this, is there any method that i can rename a file inside the javascript ? thanks in advance for your help .

最佳回答

它是Javascript(在浏览器中),正确吗?

If you run in the browser it is not allowed for security reasons. I think there is some way to do this using IE and ActiveX but using Pure Javascript I think it is not possible.

但是,在圣经中,你可以这样做,例如删除单一档案:

function MoveFile2Desktop(filespec)
{
   var fso;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   fso.MoveFile(filespec, "newname");
}
问题回答

无,你不能改用 j子。 Java稿无法以任何方式与用户计算机进行互动,只能用于与它所登网页的内容进行互动。

Java本无法与档案系统互动。

东道方可能提供这种手段。

可从一个典型的网络浏览器的网页上装出的Java文本的东道标(window)。 不允许网页上张贴访问网站人员的磁盘。 (只有EE,有主动X,有安全警告)。

If you were running JavaScript in a browser extension or in a different environment (such as node.js) then it might be possible.





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签