Reputation: 271
I have a problem for my JavaScript pop up window. I got two window pop up functions:
The first one window pop up will open a new window contains a page URL
Look like:
<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()}
}
The second window pop up will grab the content in this HTML page and show the content in pop up window.
For instance;
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>
The 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()}
}
If I run the contactForm pop up function first, and then I click on the showBox function. I got an error message in JavaScript:
Permission denied for to get property Window.document from Line 43
it is this line of code
showBoxPopupWin.document.write (orgin_div_content);
I would like to have different pop up windows.
Upvotes: 1
Views: 857
Reputation: 536379
showBoxPopupWin =window.open("",'name', ...
Won't open a new blank writable document in the window if the window called 'name'
is already open. It will keep the old document, which, being an external link, you can't write to.
You will have to open a window with a different name (usually _blank
, to prevent any window name clashes).
(Also consider giving your local variables var
to avoid accidental global clashes, and using proper links with href
instead of JS-only faux-links.)
Upvotes: 1