2

I want to save an HTML file to disk, and make it possible to be opened in most browsers without warnings (no web-server scenario).

For IE normally I used to go with "mark of the web", which was safely ignored by most browsers (in particular, by Firefox and Chrome). IE after finding this mark of the web also behaved properly and did not display any warnings. You can check more on what mark of the web is in MSDN.

Now the problem. Microsoft Edge after seeing this "mark of the web" shocks and stops executing included javascripts files. What the hell ?! If I remove the "mark of the web" and open file in Edge, it opens normally (without warnings, and javascripts are executed).

Can I make both IE and Edge work for the same file?

index.html

<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
    <script src="foo.js" ></script>
</head>
<body>
</body>
</html>

foo.js

 alert('i am executed');

The above does not execute in Edge at all (if opened from file system)! How to make it happen?

6
  • It was an IE hack. Edge is not IE Commented Jan 8, 2017 at 21:56
  • Yea, I suspect it was sort of a hack actually. But anyways, any ideas how to make it happen? I mean, FF and Chrome just ignore this tag. Why couldn't edge do the same? Commented Jan 8, 2017 at 21:59
  • 1
    Hi, remove the alert statement... (its being called from the head block) Edge and IE (now) treat alert statements with caution to prevent fake support scams.... I have no trouble running scripted MOW pages in edge although all scripts are inline and images are data uri's to make a single page without dependencies. Commented Jan 9, 2017 at 4:16
  • Thank you rob. Inline scripts work in Edge, but they are pretty big, and I'd like to keep them separate and not duplicate in each file. 'alert' does not seem to be a problem, it's just an example - any javascript code is not executed from (external) javascript files. Commented Jan 9, 2017 at 9:43
  • Hi Nik, Open edge in a blank page (about:blank) then open the dev tool (f12) and select the debug tab, on the debug tab, select "Break on all exceptions" from the dropdown (looks like a stop sign), then (!important) without closing the Edge dev tool, return to the blank page in edge and TYPE in the file address of your page.... It should now break on exceptions. Commented Feb 27, 2017 at 1:45

1 Answer 1

2

You need a mark-of-the-web on foo.js as well. There are several ways to apply a mark-of-the-web to a non-HTML file -- you can set its integrity level to "low":

icacls foo.js /setintegritylevel low

Or you can add an alternate data stream with a zone identifier:

powershell -c add-content foo.js -stream Zone.Identifier -value "[ZoneTransfer]","ZoneId=3"

Or maybe the easiest way is to rename index.html to index.htm and then put foo.js in a directory called index_files. Anything in that directory is always allowed to be loaded, even if it doesn't have its own mark-of-the-web.

Sign up to request clarification or add additional context in comments.

1 Comment

WOW. Amazing :) Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.