【发布时间】:2018-10-27 06:50:20
【问题描述】:
我在本地系统中存储了一个 html 页面,我尝试获取内容然后写入 iframe。
<html>
<head>
<title></title>
<script src="js/jquery.min.js" type="text/javascript"></script>
<link href="styles/myStlye.css" rel="stylesheet" type="text/css" />
</head>
<body><button id="buttonClick">Click Me</button></body>
<script>
$(document).ready(function(){
$("#buttonClick").click(function(){
alert("Button clicked.");
});
});
</script>
</html>
我使用 document.write() 将 html 代码写入 iframe,但在 IE9 中加载页面时出现错误 SCRIPT5009: '$' is undefined,但在 google chrome 和 firefox 中工作正常.
【问题讨论】:
-
有时$会出现问题。改用 jQuery
-
试试 jquery cdn。
-
呃,
'$' is undefined发生在当您单击按钮时?这听起来很奇怪,因为处理程序中没有$,如果没有定义$,它应该在页面加载时抛出错误。 -
尝试使用jQuery和jquery cdn,问题没有解决。我改变了我的问题,页面加载时出现错误。
标签: javascript jquery html internet-explorer-9