2010-12-13 52 views
1

我的JavaScript弹出窗口有问题。我有两个窗口弹出功能:Javascript WIndows弹出功能冲突

第一个窗口弹出将打开一个新窗口包含页面URL

样子:

<a class="" onclick="kmt_contactFormPopup('http://uk.support.tomtom.com/app/ask',this)">[To the contact form..]</a> 



function kmt_contactFormPopup(emailURL, aTag) 
{ 
    params = 'width=950px'; 
    params +=',height=700'; 
    params += 'screenX=250, screenY=80,'; 
    params +='scrollbars=yes'; 
    newwindow=window.open(emailURL,'name',params); 

    if (newwindow.focus) {newwindow.focus()} 
} 

第二个窗口弹出将抓住内容在此HTML页面中,并在弹出窗口中显示内容。

例如;

Collect the error log <a href="#BOX01" onclick="kmt_ShowBoxPopup('BOX01', this);"><strong>[Show me how..]</strong></a><br /><br /> 
<div id="BOX01" style="display:none"> 
    <table cellspacing="0" cellpadding="0" border="0" style="background-color:#ffffff;"> 

     </tr> 
    </table> 
</div> 

JavaScript的

function kmt_ShowBoxPopup(targetDivID, aTag) 
    { 
    var orgin_div_content=document.getElementById(targetDivID).innerHTML; 

    showBoxPopupWin =window.open("",'name','height=400,width=710,screenX=250,screenY=80, scrollbars=yes'); 

    showBoxPopupWin.document.write (orgin_div_content); 

    if (window.focus) {showBoxPopupWin.focus()} 
} 

如果我运行联系形式弹出功能第一,然后我点击showBox功能。我在JavaScript中的错误消息:

权限遭拒,从 获取属性Window.document 43

行是这行代码

showBoxPopupWin.document.write (orgin_div_content); 

我想有不同的弹出视窗。

回答

1
showBoxPopupWin =window.open("",'name', ... 

不会在窗口中打开一个新的空白文档写如果调用'name'的窗口已经打开。它将保留旧文档,这是一个外部链接,不能写入。

您将不得不打开一个不同名称的窗口(通常为_blank,以防止任何窗口名称冲突)。

(还要考虑与href,而不是JS-仅人造链接给你的局部变量var,以避免意外冲突世界,并使用正确的链接。)