www.webdeveloper.com
Results 1 to 7 of 7

Thread: Can't acess opened window DOM

  1. #1
    Join Date
    Aug 2009
    Posts
    13

    Exclamation Can't acess opened window DOM

    Hello everyone, i know this question may have been asked many times before but i really can't find a solution to it!

    I'm opening a new window and trying to set the visibility style for one of the child window's buttons but it seems nothing of which i tried is working, here's the latest code i'm trying but it won't work
    Code:
    var newWin=window.open("window_1.html", "_blank", "");
    newWin.onLoad = function() {
      newWin.document.getElementById("return").style.visibility="hidden";
    }
    what I've managed to get it work is to check for opener value in the child window if it doesn't equal to null and it worked
    Code:
    //child window
    function chkOpen() {
        if (window.opener != null) {
            document.getElementById("return").style.visibility="hidden"
        }
    }
    But i really need to know if i can access a child window's DOM from the opener code?

  2. #2
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,456
    Hi there Kaspro,

    does this help...
    Code:
    
       var newWin=window.open('window_1.html','_blank','');
    
    newWin.onload=function() {
       alert(this.document.documentElement.innerHTML);
       alert(this.document.body.innerHTML);
     }
    coothead

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    try this

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>123</title>
    <script>
    var newWin;
    function zz(){
    try{newWin.document.getElementById("return").style.visibility="hidden";}
    catch(e){setTimeout('zz()',100);}
    }
    window.onload=function(){
    document.getElementById('wo').onclick=function(){
    newWin=window.open("window_1.htm", "", "height=500,width=500,scrollbars=no,statusbar=no,menubar=no,top=100,left=100");
    zz();
    }
    }
    </script>
    </head>
    <body>
    <center><br /><br /><br /><br /><br /><input type="button" id="wo" value="Open child window" /></center>
    </body>
    </html>
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  4. #4
    Join Date
    Jan 2004
    Location
    chertsey, a small town s.w. of london, england.
    Posts
    1,456
    Hi there Padonak,

    don't you think that using....
    Code:
    
    <center><br /><br /><br /><br /><br />
    ...is a rather naughty.



    coothead

  5. #5
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    who cares lol ))) just was too lazy to write styles
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  6. #6
    Join Date
    Aug 2009
    Posts
    13
    Quote Originally Posted by Padonak View Post
    try this

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>123</title>
    <script>
    var newWin;
    function zz(){
    try{newWin.document.getElementById("return").style.visibility="hidden";}
    catch(e){setTimeout('zz()',100);}
    }
    window.onload=function(){
    document.getElementById('wo').onclick=function(){
    newWin=window.open("window_1.htm", "", "height=500,width=500,scrollbars=no,statusbar=no,menubar=no,top=100,left=100");
    zz();
    }
    }
    </script>
    </head>
    <body>
    <center><br /><br /><br /><br /><br /><input type="button" id="wo" value="Open child window" /></center>
    </body>
    </html>
    Hello and sorry for late response, actually this works, so it's all about waiting for the child window to get fully loaded, right???

  7. #7
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    absolutely )
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles