无法在Microsoft Edge浏览器的外部文件中运行JavaScript [英] Unable to run JavaScript in external file in Microsoft Edge browser

查看:374
本文介绍了无法在Microsoft Edge浏览器的外部文件中运行JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一段JavaScript使用Microsoft Edge运行,但是当JavaScript代码保存在外部.js文件中时,它不会运行。没有错误被返回,我可以很容易地从调试器中得到的是该函数不存在。该代码在IE 11,Chrome 45和Firefox 39中运行得非常好。嵌入在HTML页面中的JavaScript本身总是可以正常工作。

有人可以给我一个指导我做错了什么?



HTML文件名为hjt01.htm,外部JavaScript文件名为hjt01.js(与

相同的目录中)

  function externalbox(){alert(Clicked!)}  

 <!DOCTYPE HTML><! -  saved from url =(0014)about:internet  - >< html>< head>< meta http-equiv =Content-Typecontent =text / html; charset = iso-8859-1>< meta name =GENERATORcontent =页面描述>< meta http-equiv =pragmacontent =no-cache>< title>网页标题< / title>< meta name =descriptioncontent =页面描述>&l t; script language =javascripttype =text / javascriptsrc =hjt01.js>< / script>< script language =javascripttype =text / javascript> function internalbox() {alert(Clicked!)}< / script>< / head>< body id =pagedetail>< a href =javascript:externalbox();>外部< / a>< ;< a href =javascript:internalbox();>内部< / a>< / body>< / html>  $ b 

我已经搜索了网页,但找不到任何相关信息。我曾尝试在Edge的F12开发人员工具中将编辑JavaScript设置设置为启用,但这没有什么区别。



我有Edge的版本20.10240.16384.0。 / p>

解决方案

我在Microsoft Edge团队工作。

这绝对是对Internet Explorer行为的一种回归,在这种情况下这种行为有效,并继续在Windows 10上运行。我将确保我们的团队意识到问题并努力解决问题。



我会在问题解决后更新此答案。


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.

解决方案

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.

这篇关于无法在Microsoft Edge浏览器的外部文件中运行JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆