[英]Javascript doesn't seem to work for html page with html tags inside framesets
我想在没有<body>
标记的网站上运行以下JavaScript,它由<framesets>
以嵌套文档。
document.onclick= function(event) {
if (event===undefined)
event= window.event;
var target = 'target' in event ? event.target : event.srcElement;
alert("clicked");
};
我正在处理的HTML文档非常奇怪,因为我从未见过这样的事情。 无论如何,JavaScript将无法运行,但不会显示错误消息。 Firebug仅返回HTML xPath,而不返回整个/ html / frameset / frame / html / body / div / a,因此我可以看到使用frameset标签存在一些问题。 请注意,我无法控制要测试的目标站点。
<html>
<head>
<title>weird site...</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="IE=EmulateIE8" http-equiv="X-UA-Compatible">
</head>
<frameset frameborder="0" border="0" framespacing="0" cols="*,796,*">
<frame scrolling="no" noresize="noresize" src="/main/left.php" name="links" style="background-color: transparent;">
<html>
<body>
<div>
<a>text</a>
</div>
....
</body>
</html>
</frame>
<frameset frameborder="0" border="0" framespacing="0" rows="58,*">
<frame scrolling="no" noresize="noresize" marginheight="0" marginwidth="0" src="/main/top.php" name="oben" style="background-color: transparent;">
<html>
<body>....</body>
</html>
</frame>
<frameset frameborder="0" border="0" framespacing="0" cols="116,680">
<frame scrolling="no" noresize="noresize" marginheight="0" marginwidth="0" src="/main/login.php" name="persoenliches" style="background-color: transparent;"></frame>
<frame scrolling="auto" noresize="noresize" marginheight="0" marginwidth="0" src="/main/index.php" name="mitte" style="background-color: transparent;"></frame>
</frameset>
</frameset>
<frame scrolling="no" noresize="noresize" src="/main/right.php" name="heartbeat"></frame>
<noframes></noframes>
</frameset>
</html>
您要将Javascript代码放在哪里? 请记住,每个不同的框架都是一个独立的页面,其中包含单独的windows
(全局变量)和documents
因此您不能在一个地方编写事件处理程序并期望它对每个人都有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.