Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access denied to createPopup object --Help!!! 1

Status
Not open for further replies.

Orgdoctor

Technical User
Jan 8, 2003
13
US
I'm trying to use the createPopup command to get around eBay's prohibition of the use of window.open in its seller html displays. I want to use it to display supersized versions of my pictures. Here's my code for the function that is supposed to execute the popup:

function ShowPopup()
{
var pop = window.createPopup();
pop.document.body.outerHTML = "<body nclick=\"clickPopup
();\" > ... etc. (the html for the body of the popup)
pop.show(660,winheight,25,150);
return false;
}

It refuses to execute the pop.document.body.outerHTML or the pop.show commands, giving me an "Access denied" error message, both in FrontPage 2003 and in IE 6.

I have all popup blocking software turned off.

Any idea how to overcome this problem? Thanks for any help
you can provide.
 
What you can do is creating a "false" popup eg : an hidden div with absolute position (style="display:none;position:absolute") that initially contains nothing.
When you want your "popup" to be displayed, fill the div (using innerHTML method) with the HTML code you want and display it passing its style from "display : none;" to "display : block".

The only other thing to do is to build a "close" button in your div that'll pass display to none again (a clear div content) when clicked.

Water is not bad as long as it remains outside human body ;-)
 
Orgdoctor,

If you want to access of the outerHTML for the purpose of adding your event handler, you can do it like this. (Just to remind that it for ie to start with).
[tt]
var pop = window.createPopup();
pop.document.body.onclick=clickPopup;
[/tt]
outHTML itself may well be readonly for popup.

- tsuji
 
Thanks to Tsuji and especially Targol for putting me on the right track with the hidden div. However, I have one remaining problem with the hidden div: Whenever it is made visible or closed (i.e., made hidden again), the main window scrolls to the top. I've tried all the windows.scrollTo() and windows scrollBy() commands in various places, as you'll see below, but none of them return the window to the original vertical position before the div was made visible. Here is my code:

<html>

<head>

<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Product Specification</title>

<style type="text/css">
.supersize {background-color:#ffffff; layer-background-color:#ffffff;position:absolute;top:300px; left:150px; width:660px;
visibility:hidden;}
</style>

<script>
var PicNum= "Pic1";
var Winheight = "705";

function toggleBox(DivID, iState) // 1 visible, 0 hidden
{
if(document.layers) //NN4+
{
document.layers[DivID].visibility = iState ? "show" : "hide";
// window.scroll(0,1000); //doesn't work


}
else if(document.getElementById) //gecko(NN6) + IE 5+
{
var obj = document.getElementById(DivID);
obj.style.visibility = iState ? "visible" : "hidden";
// alert("supersize is now visible. Window has not scrolled.")
window.scrollTo(0,300); //doesn't work

}
else if(document.all) // IE 4
{
document.all[DivID].style.visibility = iState ? "visible" : "hidden";
// window.scroll(0,300); //doesn't work
}
}

</script>


</head>

<body>

<div id="pic1" align="center" class="supersize" style="height:705px;">
<table border="0" style="border-collapse: collapse" width="100%" height="100%" bgcolor="#FFFFFF" id="table1">
<tr>
<td align="center" valign="center" width="100%" height="95%" >
<IMG width="100%" height="100%" border="0"
src=" </td>
</tr>
<tr>
<td align="center" border="0" width="100%" height ="5%" valign="top">
<a href="#" onclick="toggleBox(PicNum,0);window.focus;window.scrollTo(0,300);">Close</a>
</td>
</tr>
</table>
</div>

This is the anchor tag with the hyperlink that is clicked to trigger the display of the hidden div:

<a href="#"><img src=" border="0"
onclick="toggleBox(PicNum,1);window.focus;window.scrollTo(0,300);">

Notice I also added a windows.scrollTo() command to the onclick event of the above <a> tag but this doesn't work either.

I do notice that if I put an alert right after the statement in the togglebox function that makes the hidden div visible, the window has not scrolled yet. So whatever is causing it to scroll is happening after the function executes.

Again, my thanks in advance for any help that anyone can provide.
 
Use "display:none" or "display:block" instead of "visibility" style attribute that'd solve your problem. You should have to add a positive z-index to the "popup" div also to be sure it'll apear above other elements on page.

Water is not bad as long as it remains outside human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top