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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation onClick open in original window: HELP!!

    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 at the same time.

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

    Also, how should I convert the checkbox links to the normal <a href> ones??

    here s the code:
    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' 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>
    thanks,

    VatsaL

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onClick=window.opener.document.location.href='http://www.microsoft.com/'

    To change them to normal links you'll need to replace the relevant parts with anchors eg.

    message+="<a href='http://www.microsoft.com/' onBlur='window.close();'>Microsoft Corp.</a>";

    That Javascript looks fairly old though as the font tag isn't used anymore...
    Last edited by mark87; 11-12-2006 at 02:13 AM.

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87 View Post
    onClick="parent.location.href='http://www.microsoft.com/'"
    Dosent work!!
    here is the page with the CHANGED onClick command (onClick="parent.location.href)

    http://www.b3ta.cr3ation.co.uk/data/htm/links.htm

  • #4
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Look at my updated post above. ^

  • #5
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It still looks like document.location.href not parent in the example link you have.

    david_kw

  • #6
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by david_kw View Post
    It still looks like document.location.href not parent in the example link you have.

    david_kw
    the example link was AFTER I modified the code according to the first suggestion.

    The first original code without any modifications is posted in the first ever post.

  • #7
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try my edited post above. ^

    Also to make the anchors link to the original window you'd have to do something like:

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

  • #8
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87 View Post
    onClick=window.opener.document.location.href='http://www.microsoft.com/'

    To change them to normal links you'll need to replace the relevant parts with anchors eg.

    message+="<a href='http://www.microsoft.com/' onBlur='window.close();'>Microsoft Corp.</a>";

    That Javascript looks fairly old though as the font tag isn't used anymore...
    Hey javascript does work, but microsoft.com would open up in the same popup window, and NOT in the parent window, where the button was located.

    It seems obvious that it would, because when the links opened in a new window, the popup window got a chance to get "blurred" and then close according to the function is was given.

    But I need to combine the onClick function, so that when the user clicks, the popup first closes, and then the parent window would open up with the link.
    Is that possible??
    oh, n the script is a bit old!!

    thanks,

    VatsaL

  • #9
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hehe we're getting a bit confused posting while eachother is posting!

    Try the updated code (again)...

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

  • #10
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87 View Post
    Try my edited post above. ^

    Also to make the anchors link to the original window you'd have to do something like:

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

    okay, the code works, the link opens in the parent window, but the popup window dosent close, as it does not get a chance to be blurred!
    can it be combined to the onclick function or something like that, so that the opening of the new link AND the closing of popup happens at the same time??

    with your code, the link DOES open in the parent window, but the popup wont close as it remains in focus while the link opens in the parent window!!
    Last edited by VatsaL; 11-12-2006 at 02:25 AM.

  • #11
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It should do it automatically... can you update the online page again to the latest code you have so far?

  • #12
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87 View Post
    It should do it automatically... can you update the online page again to the latest code you have so far?
    here it is, the first link.

    http://www.b3ta.cr3ation.co.uk/data/htm/787links.htm

  • #13
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah I see, what's happening is it's not changing the focus from the popup so onblur is not running until you click back to the main window.

    Try setting the focus back to the main window.

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

    You could also just skip the onblur and close the window when a link is clicked (probably simpler).

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

  • #14
    New Coder
    Join Date
    Nov 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mark87 View Post
    Ah I see, what's happening is it's not changing the focus from the popup so onblur is not running until you click back to the main window.

    Try setting the focus back to the main window.

    message+="<a href='#' onclick=window.opener.document.location.href='http://www.microsoft.com/';window.opener.focus() onblur='window.close();'>Microsoft Corp.</a>";
    YAYAYAYAYAY IT WORKS BEAUTIFULLY!!
    THANKS A BILLION
    that was the only thing left to complete my site.
    actually I am making a hybrid type search engine, which I hope will suit the needs for every homepage. Still have to add some tools, for which I needed the code, thanks.


    VatsaL
    Last edited by VatsaL; 11-12-2006 at 02:37 AM.

  • #15
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No problem, glad I could I help ; stick around!

    It looks good to me but if you want a proper review, ask for one in the reviews section.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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