Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript question

Options
  • 08-07-2006 10:58pm
    #1
    Registered Users Posts: 4,413 ✭✭✭


    Hello, I want to know how do I open a new window using java script from a linked image, I know how to do it from just normal text, here is my code window.open('http://www.blahblahwhatever.net', 'sty', 'location=yes,height=500,width=500', false); but how do I apply that to an image thanks.

    P.S ive looked for tutorials around the internet but cant find any.


Comments

  • Registered Users Posts: 32,136 ✭✭✭✭is_that_so


    By linked image I assume you mean a hypelink image. Try this


    <a href=javascript:void(0); onclick="window.open('http://www.blahblahwhatever.net', 'sty', 'height=500,width=500');"><img src="images/bla.jpg" height="20" name="image" border="0"></a>


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    is_that_so wrote:
    By linked image I assume you mean a hypelink image. Try this


    <a href=javascript:void(0); onclick="window.open('http://www.blahblahwhatever.net', 'sty', 'height=500,width=500');"><img src="images/bla.jpg" height="20" name="image" border="0"></a>
    Sorry, I'll just expand on this. Not everyone uses javascript, though it is possible to have a new window open for non-javascript users.
    It's essentially the same code, with a little addition:

    <a href="http://www.blahblahwhatever.net&quot; target="_blank" onclick="window.open('http://www.blahblahwhatever.net', 'sty', 'height=500,width=500');return false;"><img src="images/bla.jpg" height="20" name="image" border="0"></a>

    What this basically does:
    1. User clicks link
    2. If they're using Javascript, it opens the window. As soon as the window opens, execution ceases, preventing the "a href" command from executing
    3. If they're not using javascript, the page opens in a new window.

    :)


  • Registered Users Posts: 4,413 ✭✭✭chupacabra


    Thanks you guys, much appreciated :D


  • Registered Users Posts: 46 nogihno


    seamus wrote:
    Sorry, I'll just expand on this. Not everyone uses javascript, though it is possible to have a new window open for non-javascript users.
    It's essentially the same code, with a little addition:

    <a href="http://www.blahblahwhatever.net&quot; target="_blank" onclick="window.open('http://www.blahblahwhatever.net', 'sty', 'height=500,width=500');return false;"><img src="images/bla.jpg" height="20" name="image" border="0"></a>

    What this basically does:
    1. User clicks link
    2. If they're using Javascript, it opens the window. As soon as the window opens, execution ceases, preventing the "a href" command from executing
    3. If they're not using javascript, the page opens in a new window.

    :)


    Why do you need th onlick at all? just make sure the target is blank


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    The onClick action creates a scripted window, sized to 500x500. The TARGET creates a standard window, with no control over size, position, chrome, etc. Seamus has explained the process in his post, you might want to read it again.

    adam


  • Advertisement
  • Registered Users Posts: 46 nogihno


    Ken Shabby wrote:
    The onClick action creates a scripted window, sized to 500x500. The TARGET creates a standard window, with no control over size, position, chrome, etc. Seamus has explained the process in his post, you might want to read it again.

    adam


    Apologies all, will think before I type in future. carry on .........


Advertisement