我在JavaScript中打开弹窗遇到了问题,我有以下函数可以在IE6和IE7中打开我的弹窗:
function open_window(Location,w,h) //opens new window
{
var win = "width="+w+",height="+h+",menubar=no,location=no,resizable,scrollbars,top=500,left=500";
alert(win) ;
window.open(Location,'newWin',win).focus();
}
它正在工作。我的新窗口已经打开,但是出现了一个错误。错误信息如下:
'window.open(...)' 是 null 不是一个对象。
您是否要继续在此页面上运行脚本?
然后我有一个按钮,在 onclick 事件中它将调用一个函数来关闭当前窗口并刷新 opener 函数。
function refreshParent(location)
{
window.opener.location.href = location ;
window.close();
}
这也给我带来错误:window.opener.location为空或不是一个对象,但我确定我传递了正确的参数。
我像这样调用它:
对于第二部分:
<input type="button" name="pay" value="test" onclick="refreshParent('index.php?module=payment&task=default')" >
for first part :
<a onclick="javascript:open_window('?module=cart&task=add&id=<?=$res[xproductid]?>&popup=on','500' , '500')" style="cursor:pointer" id="addtocard"> <img src="../images/new_theme/buy_book.gif" width="123" border="0"/> </a>
这真的让我感到困惑。请帮忙 ;)