1

I'm trying to get a piece of JavaScript to run using Microsoft Edge, but it does not run when the JavaScript code is held in an external .js file. No errors are returned, and all I can readily get from the debugger is that the function does not exist. The code works perfectly well in IE 11, Chrome 45 and Firefox 39. The JavaScript embedded in the HTML page itself always works fine.

Can someone give me a steer as to what I am doing wrong?

The HTML file is called hjt01.htm and the external JavaScript is hjt01.js (in the same directory as

function externalbox()
{
	alert("Clicked!")
}
<!DOCTYPE HTML>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Description of page">
<meta http-equiv="pragma" content="no-cache">
<title>Webpage Title</title>
<meta name="description" content="Description of page">
<script language="javascript" type="text/javascript" src="hjt01.js"></script>
<script language="javascript" type="text/javascript">
function internalbox()
{
	alert("Clicked!")
}
</script>
</head>
<body id="pagedetail">
<a href="javascript:externalbox();">External</a>
<br />
<br />
<a href="javascript:internalbox();">Internal</a>
</body>
</html>

I've searched the Web but can't find any relevant information. I have tried setting the "Edit JavaScript" setting to Enabled in Edge's F12 Developers Tools, but this has made no difference.

I have version 20.10240.16384.0 of Edge.

4
  • Is the page being served by a server, or are you opening the file locally (i.e., "c:\...\hjt01.html")? Commented Sep 16, 2015 at 20:51
  • It's a local file. Actually, the HTML and JavaScript is being written by a program I've written, so it'll always be opened locally. The sample code above demonstrates the behaviour but has been cut down to create a minimal example. Commented Sep 16, 2015 at 21:29
  • FWIW, I did a search while still at work and found a post on StackOverflow that seemed to indicate others had run into this as well. I didn't comment here because I wanted to get home where I had a W10 machine to try it. Anyway, I can't find the other post now, but what you're seeing works the same way on my system, so it must be just the way Edge works at this point... Commented Sep 17, 2015 at 1:17
  • Thanks Tony, you're probably right. I did continue to search the Web after posting and thought I'd found something, but it turned out to be irrelevant. If I do find anything I'll come back and post my findings. Commented Sep 17, 2015 at 9:29

1 Answer 1

2

I work on the Microsoft Edge team.

This definitely appears to be a regression in behavior from Internet Explorer, where this worked, and continues to work on Windows 10. I'll ensure that our team is aware of the issue and working towards resolution.

I'll update this answer when the issue has been resolved.

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

3 Comments

Thanks Sampson - I've marked it as the answer for now.
@stealth_angoid I no longer repro this issue on a fresh internal build of Microsoft Edge/Windows 10. Other team members report that yesterday's build didn't repro for them. Please continue to apply all updates as they are available, and let me know if the problem persists.
Thanks Sampson - I keep current with all my Windows updates, and although I'm in the Insider program this is my main PC so I don't get the Insider beta updates as I can't afford to bork this machine. I've just tried it again, and same result as before. BTW, I'm running 64-bit Windows 10 Pro, clean install if that makes a difference.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.