怎样在一个窗口中调用另一个窗口对象的属性和方法?
roll.php
<html><head><title>滚动</title>
<script language="javascript" type="text/javascript" src="js.js">
</script>
<script language="javascript">
<!--
var winObj;
winObj=window.open("pic.php","mypic","width=250,height=192,resizable=no");
winObj.moveTo(0,0);
winObj.focus();
//-->
</script>
</head>
<body bgcolor="lightgreen">
<font face="宋体" size=4>
<b><br><center>
滚动新打开窗口
<form>
<input type="button" value="开始滚动" onClick="startScroll();winObj.focus();">
<input type="button" value="停止滚动" onClick="stopHere();winObj.focus();">
</form>
<font size=-1>
<p>关闭<br>
<a href="javascript:closeWindow()">关闭新打开窗口</a></h3>
</body>
</html>
pic.php
<html>
<head><title>测试</title>
<script language="javascript" type="text/javascript" src="js.js">
</script>
</head>
<body bgcolor="#ADD8E6">
<a href="http:\\www.baidu.com" target="_blank" onClick="window.close();"><img name="phto" src="1.jpg" width="200" height="172" onMouseOver="stopHere();";></a>
</body>
</html>
js.js
var pixelpos=0;
var ImgWidth=640;
var pixelstep=1;
var timeout;
/***窗口漂移******/
function startScroll(){
if(pixelstep>0){
pixelpos+=pixelstep;
winObj.moveTo(pixelpos,pixelpos);
if(pixelpos==ImgWidth-250)pixelstep=-1;
}
else{
pixelpos+=pixelstep;
winObj.moveTo(pixelpos,pixelpos);
if(pixelpos==0)pixelstep=1;
}
timeout=setTimeout("startScroll()",20);
}
function closeWindow(){
winObj.close();
}
function stopHere(){
clearTimeout(timeout);
}
我想实现鼠标移到新打开的窗体中时,窗体就停止漂移。
我在roll.php中创建了winObj窗体对象,而在pic.php中无法直接使用他的属性和方法。
pic.php中的stopHere()好象只停止了自己窗体的计时器,请问该怎么停止winObj窗体的计时器呢,或者说怎么使winObj的属性和方法在pic.php中能使用。谢谢!!