Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2003
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access denied - what am I doing wrong?

    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.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are popups in IE6 enabled?

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    De gustibus non est disputandum.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);
    }
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #6
    New Coder
    Join Date
    Jul 2003
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all your help guys, the script works fine now.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •