找到新的窗口HREF我使用下文提到的脚本来获得新打开的窗口中的HREF,但其没有工作无法使用JavaScript
浏览器FF 7,IE 9,WIN 7
可有人请让我知道什么是错的脚本
由于提前
AKHIL
<html>
<head>
<script type="text/javascript">
function open_win()
{
var mywindow=window.open("http://thesun.co.uk");
var clbutton=document.createElement("button");
var par=document.getElementById("main");
clbutton.setAttribute("id","focus");
clbutton.setAttribute("value","CLICK");
clbutton.innerHTML="CLICK";
par.insertBefore(clbutton,null);
clbutton.onclick=function() {alertMsg(mywindow);}
}
function alertMsg(mywindow)
{
mywindow.focus();
var t=mywindow.location.href;
alert(t);
//mywindow.alert("testing");
mywindow.close();
}
</script>
</head>
<body onload="open_win()">
<p id="main"></p>
</body>
</html>
你碰巧有“不安全的JavaScript尝试从URL http://www.thesun.co.uk/sol/homepage/与框架URL访问框架...”或“mywindow为null”在您的消息安慰? – ZenMaster