Run local 'Javascript Dependant' HTML file in Internet Explorer

北城余情 提交于 2019-12-22 08:40:24

问题


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?


回答1:


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>



回答2:


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



来源:https://stackoverflow.com/questions/15939105/run-local-javascript-dependant-html-file-in-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!