I want to run the following JavaScript on a site with no <body> tag and it consists of <framesets> to nest documents.
document.onclick= function(event) {
if (event===undefined)
event= window.event;
var target = 'target' in event ? event.target : event.srcElement;
alert("clicked");
};
The HTML document I am dealing with is quite bizarre as I’ve never seen anything like this. Anyhow, the JavaScript will not run but no error message is shown. Firebug returns only the HTML xPath, not the entire/html/frameset/frame/html/body/div/a, so I can see there is some problem with having frameset tags. Note I have no control over the target site I am supposed to test.
<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>
Where are you putting your Javascript code? Remember that each different frame is an independent page, containing separate
windows(global variables) anddocumentsso you can’t write an event handler in one place and expect it to work for everyone.