JavaScript帧交互问题 先看下这里的运行效果http://www.izhaoyang.com/test/main.htm运行两次完全相同的alert(),显示却不一样,我不明白请高手赐教,也可以通过qq联系我,411908279 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 main.htm<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Main</title><script type="text/javascript"> <!-- <![CDATA[ var G = "Main.htm"; // ]]> --></script></head><body topmargin="0" leftmargin="0" bottommargin="0" rightmargin="0"><iframe id="top" name="top" src="Top.htm" width="100%" height="20%"></iframe><iframe id="left" name="left" src="Left.htm" width="20%" height="80%"></iframe><iframe id="page" name="page" src="Page.htm" width="80%" height="80%"></iframe><script type="text/javascript"> <!-- <![CDATA[ alert(frames[0].G); alert(frames[0].G); // ]]> --></script></body></html>top.htm<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>标题</title><script type="text/javascript"> <!-- <![CDATA[ var G = "Top.htm"; var $ = function(ID) { return document.getElementById(ID); }; // ]]> --></script></head><body><label id="label1">label1</label><br /><label id="label2">label2</label><br /><label id="label3">label3</label></body></html>left.htm<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Left</title><script type="text/javascript"> <!-- <![CDATA[ var G = "Left.htm"; // ]]> --></script></head><body></body></html>page.htm<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>标题</title><script type="text/javascript" src="Bounce.js"></script><script type="text/javascript"> <!-- <![CDATA[ var G = "Page.htm"; window.onerror = function(msg, url, line) { alert(url + "\n____________________________________________________________" + "\n\nLine:" + line + "\nError:" + msg); return true; }; (function() { var _start = new Date(); function _elapsed() { var now = new Date(); var elapsed = Math.round((now - _start) / 1000); window.defaultStatus = "You have wasted " + elapsed + " second."; } setInterval(_elapsed, 1000); })(); // ]]> --></script></head><body><button onclick="Bounce.start()">开始</button><button onclick="Bounce.stop()">停止</button></body></html> <script type="text/javascript"> <!-- <![CDATA[ alert(frames[0].G); alert(frames[0].G); // ]]> --></script>这里运行的2次alert()结果不一样,如果按下边这么运行都有返回值<script type="text/javascript"> <!-- <![CDATA[ alert(G); alert(frames[0].G); // ]]> --></script>不知道是那里出问题了,请高手赐教。 自己解决了...突然想起书上说,在HTML文档还没有载入完成的时候并不稳定,所以试了下这么写就成功了window.onload = function() { alert(frames[0].G);} jquery easyui datagrid 动态增加行 如何使用javascript实现验证文本编辑器非空的方法???? web前端(js 求助) 困惑 Ext.ux.FusionPanel html 嵌套HTML页面 contains 急~随页面上下浮动的“top”是怎么弄出来的啊~ 在JavaScript中有等价于ASP中Response.End的语句吗? 用javascript如何控制复选框必须有一个选定亚? 刷新页面时能不能不让它闪啊? 有米有高手能实现在表格和树之间拖动数据 正则表达式 匹配问题
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Main</title>
<script type="text/javascript">
<!-- <![CDATA[
var G = "Main.htm";
// ]]> -->
</script>
</head><body topmargin="0" leftmargin="0" bottommargin="0" rightmargin="0">
<iframe id="top" name="top" src="Top.htm" width="100%" height="20%"></iframe>
<iframe id="left" name="left" src="Left.htm" width="20%" height="80%"></iframe>
<iframe id="page" name="page" src="Page.htm" width="80%" height="80%"></iframe>
<script type="text/javascript">
<!-- <![CDATA[
alert(frames[0].G);
alert(frames[0].G);
// ]]> -->
</script>
</body>
</html>top.htm
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>标题</title>
<script type="text/javascript">
<!-- <![CDATA[
var G = "Top.htm"; var $ = function(ID) {
return document.getElementById(ID);
};
// ]]> -->
</script>
</head><body>
<label id="label1">label1</label><br />
<label id="label2">label2</label><br />
<label id="label3">label3</label>
</body>
</html>left.htm
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Left</title>
<script type="text/javascript">
<!-- <![CDATA[
var G = "Left.htm";
// ]]> -->
</script>
</head><body>
</body>
</html>page.htm
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>标题</title>
<script type="text/javascript" src="Bounce.js"></script>
<script type="text/javascript">
<!-- <![CDATA[
var G = "Page.htm"; window.onerror = function(msg, url, line) {
alert(url +
"\n____________________________________________________________" +
"\n\nLine:" + line +
"\nError:" + msg);
return true;
}; (function() {
var _start = new Date();
function _elapsed() {
var now = new Date();
var elapsed = Math.round((now - _start) / 1000);
window.defaultStatus = "You have wasted " + elapsed + " second.";
}
setInterval(_elapsed, 1000);
})();
// ]]> -->
</script>
</head><body>
<button onclick="Bounce.start()">开始</button>
<button onclick="Bounce.stop()">停止</button>
</body>
</html>
<!-- <![CDATA[
alert(frames[0].G);
alert(frames[0].G);
// ]]> -->
</script>
这里运行的2次alert()结果不一样,如果按下边这么运行都有返回值
<script type="text/javascript">
<!-- <![CDATA[
alert(G);
alert(frames[0].G);
// ]]> -->
</script>
不知道是那里出问题了,请高手赐教。
alert(frames[0].G);
}