Click here to Skip to main content
15,443,281 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
trying to move file using javascript or jquery .
But getting this error : ActiveXObject is not defined

What I have tried:

"DOWNLOAD"

function downloads(){
var aa = document.getElementById("a");
aa.click();

var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.GetFile("C:\\Users\\BDAS\\Downloads\\true.jpg");
file.Move("C:\\BDAS\\Desktop\\Newdownload");
document.write("File is moved successfully");

alert();
}
Posted
Updated 22-Apr-22 2:40am
v2
Comments
Richard MacCutchan 22-Apr-22 8:30am    
What part of "ActiveXObject is not defined" do you not understand?
jsc42 22-Apr-22 8:30am     CRLF
Which browser? Which OS? (ActiveXObject is only supported on MS-Windows) I use it on *.hta in a script that I wrote for W98 and it still works on W11, but it is generally not regarded as the correct way to do things.

1 solution

Sorry to tell you, but this isn't possible anymore. There isn't a browser alive today that supports ActiveXObject.

The only two browsers that used to support it were Internet Explorer and Firefox. IE is dead and Firefox no longer supports creating ActiveX objects. This is because it was found to be a massive security problem.
 
Share this answer
 
Comments
jsc42 22-Apr-22 12:47pm     CRLF
IE is not completely dead! Somewhat moribund - more like a walking zombie. You can still use CreateObject("InternetExplorer.Application") in a Windows Script File or a Hypertext Application and it starts an IE window. The standard DLL XHTML? is effectively IE7 (so HTML4 + CSS1.0 + JS1.2) but it still works even on Windows 11. ActiveX, therefore, limps along even today. However, I concur that it has the potential to be a massive security problem and should be avoided like the plague. I only use it for a couple of very old utilities that I wrote for myself years ago, so I know what the safety risks are with them. I would never pick something off the shelf that used ActiveX and have no intention of writing anything using it in the future. Caveat Emptor!
Dave Kreskowiak 22-Apr-22 13:32pm     CRLF
That may be the definition of "not completely dead" to you, but in my world, if it's no longer getting security updates, it's a dead product and cannot be used for any purpose, and that'll happen on June 15th.
mahabir das 23-Apr-22 1:47am    
any alternative of ActiveXObject ?
Dave Kreskowiak 23-Apr-22 10:55am     CRLF
No. Code running in the browser has no access to any client resources. It runs in a secured sandbox.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900