最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Run local 'Javascript Dependant' HTML file in Internet Explorer - Stack Overflow

programmeradmin0浏览0评论

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 municates 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 patibility.

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

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 municates 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 patibility.

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

Share Improve this question asked Apr 11, 2013 at 1:01 sazrsazr 26k70 gold badges214 silver badges387 bronze badges 5
  • can you append your post with information on which version of IE, and how you're causing IE to load your page? (not entirely sure what you mean with cross-platform patibility when your CD apparently relies on a windows-only autorun...?) – Mike 'Pomax' Kamermans Commented Apr 11, 2013 at 1:05
  • You want to use a Mark of the Web. See msdn.microsoft./en-us/library/ms537628%28v=VS.85%29.aspx for details, or just add: <!-- saved from url=(0014)about:internet --> below the doctype and above the opening HTML tag. – Lucas Meyer Commented Apr 11, 2013 at 1:06
  • @Mike'Pomax'Kamermans AFAIK all versions of IE have this restriction so the version is irrelevant. The reason for using HTML, CSS, Javascript is because we can create a interactive menu quickly and easily as opposed to using Winforms, Win32, DirectX, etc. – sazr Commented Apr 11, 2013 at 1:08
  • 2 You could possibly package your menu as a HTA (html application) msdn.microsoft./en-gb/library/ms536496(v=vs.85).aspx although this would stop it being cross-platform – NickSlash Commented Apr 11, 2013 at 1:10
  • Just came back to remend the HTA as another option. One could include both HTML and HTA versions. – Jeremy J Starcher Commented Apr 11, 2013 at 1:19
Add a ment  | 

2 Answers 2

Reset to default 5

You want The Mark of the Web:

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

There are three versions

  • <!-- saved from url=(0023)http://www.contoso./ -->
  • <!-- 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./ -->
<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.

发布评论

评论列表(0)

  1. 暂无评论