...

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



wickford
07-03-2003, 10: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);
popit.moveTo((screen.width/2)-(width/2),(screen.height/2)-(height/2));
}

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?

Thanks.

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

scroots

mordred
07-03-2003, 11:19 PM
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.

beetle
07-03-2003, 11:21 PM
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);
}

scroots
07-03-2003, 11:22 PM
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?

scroots

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum