Problem resizing a popup window (Permission Denied)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rizwan6feb
    New Member
    • Jul 2007
    • 108

    Problem resizing a popup window (Permission Denied)

    Hi experts! I getting the following error message from Firefox, for the given code

    Error: uncaught exception: Permission denied to get property Window.resizeTo
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="javascript">
        var w;
        var x=400; 
        var y=80;
        function showPopup(){
            w=window.open('http://www.google.com',null,'width=400,height=80,scrollbars=0,menubar=0,toolbar=0,resizable=1');
            resizeWindow();
        }
        function resizeWindow(){
            w.resizeTo(x,y);
            if(x>=700){
                w.resizeTo(x,y);
                y++;
            }
            else{
                x++;
            }
            if(y<=300){
                setTimeout("resizeWindow()",1);
            }
            else{
                clearTimeout("resizeWindow()",1);
            }
        }
    </script>
    </head>
    
    <body>
        <input type="button" value="Show Popup" onclick="showPopup()" />
    </body>
    </html>
    Last edited by rizwan6feb; May 22 '08, 01:19 PM. Reason: Missed the code tags
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    you are not allowed (by a browser) to manipulate or even look at the window object of sites that don't match the main, address bar, current url.

    you might be able to control the popup from the script using the w object, or by changing the window.open parameters.

    Comment

    • rizwan6feb
      New Member
      • Jul 2007
      • 108

      #3
      Originally posted by rnd me
      you are not allowed (by a browser) to manipulate or even look at the window object of sites that don't match the main, address bar, current url.

      you might be able to control the popup from the script using the w object, or by changing the window.open parameters.
      I have been already using the w object to resize the popup window.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        As rnd me mentioned, you can't access the window if it's from another domain.

        Either make sure the site is from your domain or load it from your domain.

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          Originally posted by rizwan6feb
          I have been already using the w object to resize the popup window.
          as it was said correctly here ... the problem is not the resize action, the problem is a cross-domain-scripting issue ... just let me put an additional link for the OP here - have a look here ...

          kind regards

          Comment

          Working...