我有两个页面,a.html和b.html:
a.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../js/prototype.js"></script>
<script type="text/javascript">
jQuery(function() {
new Ajax.Updater("mydiv", "b.html", {
method : "get",
evalScripts : true
});
});
</script>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>
b.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function sayHello() {
alert("helloWorld!");
}
</script>
</head>
<body>
<input type="button" value="click me" onclick="sayHello();" />
</body>
</html>
单独访问b.html时,点击button,能够调用sayHello()函数。然而,访问a.html时,再点击button,JS错误,sayHello未定义。各位大侠,这个应该怎样解决啊?
a.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../js/prototype.js"></script>
<script type="text/javascript">
jQuery(function() {
new Ajax.Updater("mydiv", "b.html", {
method : "get",
evalScripts : true
});
});
</script>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>
b.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function sayHello() {
alert("helloWorld!");
}
</script>
</head>
<body>
<input type="button" value="click me" onclick="sayHello();" />
</body>
</html>
单独访问b.html时,点击button,能够调用sayHello()函数。然而,访问a.html时,再点击button,JS错误,sayHello未定义。各位大侠,这个应该怎样解决啊?
解决方案 »
- 关于网页嵌套的一点疑问
- 求帮忙!!!
- document.formname.elementname.value在runat="server"时为何取不到值?
- jquery 请问下面罗列array到html为什么不成功?
- 正则提取关键字,实现csdn中code源码提出功能!
- js动态变量问题
- 点href链接时状态栏总会出现要链接的网址,就是设了 <a onmouseover="window.status='hello'" > 也还会出现网址啊,怎么不让它出现要链接的
- 用正则表达式怎么确定textbox里面是一个有效的文件名???谢谢。
- jquery获取不了新插入的节点
- AJAX绑定Select 下拉,加载的时候如何获取下拉的第一个值
- 如何用javascript抓取数据
- 我用js写的进度条在火狐中可以显示,但在ie6或ie7中不显示
说明页面找不到这个JS函数,
你确认1下,
<script type="text/javascript">
jQuery(function() {
new Ajax.Updater("mydiv", "b.html", {
method : "get",
evalScripts : true
});
});
</script>
这个语句是否执行了,然后你再alert(mydiv.innerHTML)
看下,是什么问题
页面中啊!
sayHello = function() {
...
}