View Full Version : Access denied - what am I doing wrong?

07-03-2003, 11:51 PM
Can you help please? I have a script that, when a user clicks a link, a popup window appears and positions itself in the center of the screen.

function popup(url){
var height=400, width=300;
var popit=window.open(url,'details','height='+height+',width='+width);

Here is the HTML link:

<a href="javascript: popup('http://www.google.com');"

The script works fine in Netscape and Opera, but in Internet Explorer (6.0 at least) I get an error saying that access is denied. Is this a fault with the browser or with the script?


07-03-2003, 11:54 PM
are popups in IE6 enabled?


07-04-2003, 12:19 AM
Apparently in IE the moveTo() method of the window object is restricted in its use by the Same Origin Policy.

Try the following: First open a blank window, immediately after that move it to the desired location on the screen, and then set the URL of that window with the help of location.href. That should work.

07-04-2003, 12:21 AM
Change it up a bit

function popup(url){
var height=400, width=300;
var l = (screen.width/2)-(width/2);
var t = (screen.height/2)-(height/2);
var popit = window.open(url,'details','height='+height+',width='+width+',left='+l+',top='+t);

07-04-2003, 12:22 AM
doesn't IE access the winodw width/height using a different statement/code/method to other browsers.
like window.screen.width? or document.screen/width?

or am i just talking garbage?


07-04-2003, 11:15 AM
Thanks for all your help guys, the script works fine now.