Unable to run JavaScript in external file in Microsoft Edge browser

删除回忆录丶 提交于 2019-12-08 07:48:51

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/32617995/unable-to-run-javascript-in-external-file-in-microsoft-edge-browser

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