Results 1 to 7 of 7

Thread: parent window onClick

  1. #1
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default parent window onClick

    I press a button.

    A popup opens, showing me a list of links.

    I click on a link.

    The popup closes, and the new link opens in a new window.

    what should I put instead of onClick=window.open('http://www.google.com/','') so that the link I click on opens in the
    original window
    where I pressed the button to open the popup??

    the present code of the popup window:
    Code:
    <head>
    <script language="JavaScript" type="text/javascript">
    function openWin() {
    
            display=window.open('','NewWin','menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=110,width=190')
            message="<font face='verdana, arial, helvetica, san-serif' size='2'><form>";
            message+="<input type='checkbox' onClick=window.open('http://www.google.com/','') onBlur='window.close();' />Google<br />";
            message+="</form></font>";
            display.moveTo(X,Y);
            display.document.write(message); }
    }
    // -->
    </script>
    </head>
    <body>
    <font face="verdana">
    <form><input type="button" value="Some Links" onClick="openWin()" /></form>
    </font>
    </body>
    thanks,

    VatsaL

  2. #2
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    <input type="button" value="Some Links" target="_self">

  3. #3
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by chechu View Post
    <input type="button" value="Some Links" target="_self">
    already tried that with the original code, shows error:
    Line: 39
    Char: 1
    Error: Object expected
    Code: 0


    Also, I need to convert the checkbox links to normal <a href> links, what should I do with the onClick=window.open thingy?

    code with target="_self"
    Code:
    <html>
    <head>
    <script language="JavaScript" type="text/javascript">
    <!-- Copyright 2001, Sandeep Gangadharan -->
    <!-- For more free scripts go to http://sivamdesign.com/scripts/ -->
    <!--
    var X = 200;  // change the # at the left for a fixed X co-ordinate to accommodate browsers other than IE or NS
    var Y = 200;  // change the # at the left for a fixed Y co-ordinate to accommodate browsers other than IE or NS
    
    if (navigator.appName.indexOf("Netscape")!=-1) {
    document.captureEvents(Event.MOUSEMOVE)
    function getcoords(e) {
    X = parseInt(e.screenX) - 80;  // change the # at the left to further adjust the left-margin depending on the size of the window
    Y = parseInt(e.screenY) - 60;  // change the # at the left to further adjust the top-margin depending on the size of the window
    return true;}  
    document.onmousemove = getcoords;
    
    function openWin() {
    
    if (navigator.appName.indexOf("Microsoft")!=-1) {
    X = parseInt(event.screenX) - 80;  // change the # at the left to further adjust the left-margin depending on the size of the window
    Y = parseInt(event.screenY) - 60; }  // change the # at the left to further adjust the top-margin depending on the size of the window
    
            display=window.open('','NewWin','menubar=0,location=no,status=no,directories=no,toolbar=no,scrollbars=yes,height=110,width=190')
            message="<font face='verdana, arial, helvetica, san-serif' size='2'><form>";
            message+="<input type='checkbox' target="_self" onClick=window.open('http://www.microsoft.com/','') onBlur='window.close();' />Microsoft Corp.<br />";
            message+="<input type='checkbox' onClick=window.open('http://home.netscape.com/','') onBlur='window.close();' />Netscape Corp.<br />";
            message+="<input type='checkbox' onClick=window.open('http://www.macromedia.com','') onBlur='window.close();' />Macromedia Inc.<br />";
            message+="<input type='checkbox' onClick=window.open('http://www.symantec.com','') onBlur='window.close();' />Symantec Corp.<br />";
            message+="</form></font>";
            display.moveTo(X,Y);
            display.document.write(message); }
    }
    // -->
    </script>
    </head>
    <body>
    <font face="verdana, arial, helvetica, san-serif" size="2">
      <form><input type="button" value="Some Links" onClick="openWin()" /></form>
    </font>
    </body>
    </html>

  4. #4
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    I guess Sandeep Gangadharan will be the best guy to go to ???

  5. #5
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by chechu View Post
    I guess Sandeep Gangadharan will be the best guy to go to ???
    You have a point, I'll try that!

  6. #6
    Join Date
    Nov 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Let me get this straight.

    you click on a link it opens a new window with open() or target="" ?

    then from that window you click a link & you want it to go back to the window you started from ?

    in that case
    parent.window.location = newlocation

  7. #7
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I wanted the link from the popup to open in the original window, and the popup to close, both events at the same time.

    I figured it out, though. It works by replacing the link lines with this code:

    Code:
    message+="<a href='#' onclick=window.opener.document.location.href='http://www.microsoft.com/';window.opener.focus() onblur='window.close();'>Microsoft Corp.</a>";

    or something much simpler:

    Code:
    message+="<a href='#' onclick=window.opener.document.location.href='http://www.microsoft.com/';window.close()>Microsoft Corp.</a>";

Bookmarks

Posting Permissions

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