简体   繁体   中英

Run local 'Javascript Dependant' HTML file in Internet Explorer

When you open a local HTML file (that contains Javascript) using Internet Explorer a message appears saying

Internet Explorer restricted this webpage from running scripts or ActiveX Controls

My Question: Is there a way to ask IE or the user to allow local HTML files to run javascript?

We are distributing a CD that displays our HTML based menu on AutoRun. The menu runs in the users browser and communicates infromation about whats on the CD (a Customisation Package so NOT an installer). Our menu relies heavily on JQuery so not being able to run Javascript is not good. We chose to make the menu in HTML, CSS, Javascript to achieve cross-platform compatibility.

Is there a way to automatically run Javascript from a local HTML file in IE?

You want The Mark of the Web:

http://msdn.microsoft.com/en-us/library/ms537628(v=vs.85).aspx

There are three versions

  • <!-- saved from url=(0023)http://www.contoso.com/ -->
  • <!-- saved from url=(0014)about:internet -->
  • <!-- saved from url=(0016)http://localhost -->

The formatting is very specific, down to placement and that a carriage return and linefeed must follow the closing --> .

<!doctype html>
<!-- saved from url=(0023)http://www.contoso.com/ -->
<html>
  <head>
    <title>A Mark of the Web Example.</title>
  </head>
  <body>
     <p>Hello, World</p>
  </body>
</html>

Internet Explorer should ask if you want to allow it, typically by clicking that notification. There is also a setting to permanently allow it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM