Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: One click to two links, how ???

  1. #1
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default One click to two links, how ???

    Example:
    I have a image and two links:
    Firt link: http://www.google.com
    Second link: http://www.yahoo.com
    I want only a click to image for go to the fist link (open same window) and open the second link in a new window.
    How do this work? Everybody can help?

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Change the target of the link to "_blank"

    Look here:
    Code:
    <a href="http://www.yahoo.com" target="_blank">Yahoo</a>
    - Mike

  3. #3
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt
    Change the target of the link to "_blank"

    Look here:
    Code:
    <a href="http://www.yahoo.com" target="_blank">Yahoo</a>
    Thanks for your help, but you didn't understand my idea.
    I want only a click to image for go to the fist link (open same window) and open the second link in a new window.

  4. #4
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

  5. #5
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    The easiest way: (not sure about browser compatibility)
    Code:
    <a href="javascript:void(document.getElementById("link1").click()); void(document.getElementById("link2").click())"><img src="..." alt="..." /></a>
    <a id="link1" href="http://www.google.com">Link 1</a>
    <a id="link2" href="http://www.yahoo.com" target="_blank">Link 2</a>
    Last edited by DimX; 08-20-2006 at 09:01 AM.

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    click() doesn't work for FF as I'm aware of.
    - Mike

  7. #7
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by shachi
    The following script allows one button to have two or more functions
    On the first press function one is run, on the second press function two is run.
    To show how this works I have used an alert box as function one and two.
    Thank you, but only a click - one press, not two.

    click() doesn't work for FF as I'm aware of.
    I has just tested, it's right.

    Anyone, please!

  8. #8
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Quote Originally Posted by mburt
    click() doesn't work for FF as I'm aware of.
    Yeah, that's true.

    But this should work:
    Code:
    <script type="text/javascript">
    function openOtherLinks(id1, id2) {
        var link1 = document.getElementById(id1);
        var link2 = document.getElementById(id2);
        if(!link1.href || !link2.href)
            return;
        window.open(link2.href);
        document.location.replace(link1.href);
    }
    </script>
    Code:
    <a href="javascript:openOtherLinks('link1', 'link2')"><img src="..." alt="..." /></a>
    <a id="link1" href="http://www.google.com">Link 1</a>
    <a id="link2" href="http://www.yahoo.com" target="_blank">Link 2</a>

  9. #9
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeah, It works. Thanks a lot

    But, I can't use BACK button for return to the page include image after go to the firt link (google.com).

    Can you fix this error ???
    Last edited by i777; 08-19-2006 at 07:10 PM.

  10. #10
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Can anyone help me, please!

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
  •