Results 1 to 3 of 3

Thread: Open a New Window

  1. #1
    Join Date
    Mar 2010
    Location
    Canada
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Open a New Window

    when a user click on a link, it would open a new window in HTML it is something like this:
    Code:
    <a href="http://google.com" target="_blank">click here</a>

    How do I do this in Javascript? So a user would click on the link and it would open a new window. Here's my code
    Code:
    document.writeln('<tr><td>' + "http://google.com" + '</td></tr>');
    I know window.open(url) would open a new window, but how do I make it clickable??

    Any comments or suggestion would be greatly appreciated.
    thanks

  2. #2
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    It really depends on your implementation. What kind of element/object are you trying to make clickable? Any chance we could see some source?
    Verzeihung!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If you're using document.writeln(), you can do:

    Code:
    document.writeln('<tr><td><a href="http://google.com" target="_blank">click here</a></td></tr>');
    Or, if
    Code:
    http://google.com
    is a stand in for a variable assigned earlier:

    Code:
    document.writeln('<tr><td><a href="' + somevariable + '" target="_blank">click here</a></td></tr>');
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •