JS implementation open a local file or folder

Source: Internet
Author: User

Original website: http://blog.csdn.net/cofesun/article/details/7904887
JavaScript has a special object ActiveXObject that allows access to the local file system and applications of Windows
<Script> functionopenfileiis (filename) {Try{ varobj=NewActiveXObject ("Wscript.Shell"); if(obj) {obj. Run ("\""+filename+"\"", 1, false ); Obj=NULL; } }Catch(e) {alert ("please determine if the drive letter or file exists"); } }
</Script>
if the new ActiveXObject ("Wscript.Shell") creation failure should be handled like this

JavaScript uses new ActiveXObject ("Wscript.Shell") to create an object that appears: The Automation server cannot create an object error because of

One, the component is not registered, you can use the following methods:

Start-"Run-" regsvr32 c:\WINDOWS\system32\shell32.dll
Start-"Run-" regsvr32 c:\WINDOWS\system32\WSHom.Ocx
Start-"Run-" regsvr32 c:\WINDOWS\system32\scrrun.dll

If the hint is missing that DLL or OCX, then go to download it online or copy it to another computer.

Second, the browser settings (this method on IE6), you can use the following methods:

Tools-"Internet Options-" security-"Trusted sites-" site-"Remove the check boxes below that Require security verification, add your URLs, confirm, and then select the check boxes that require verification."

With the above settings, this component has been created, but is limited and is not recommended for use by websites.

JS implementation open a local file or folder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.