SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict nodding dino's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    link within <td> but with target="blank" ?

    OK...i found a thread and pinched some code suggested by JeffLange to turn a <td> into a link...

    PHP Code:
    <td style="cursor: pointer" onclick='window.location.href="http://link/to/your/site/";'
    this works just peachy, but i would also like to use the target="blank" attribute...and am not sure how to (excuse the pun) tag it on?

    Thanks in advance!

  2. #2
    SitePoint Member
    Join Date
    May 2004
    Location
    UK
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use javascript to open the new window - not sure why you would want to put a link on a td though!

    write function that opens the window and pass the url to the function via the onclick thing.

  3. #3
    SitePoint Addict nodding dino's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a long story - what the client wants...the client gets etc!!!

    am not too crash hot with javascript...any chance of pointing me in the right direction?

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2004
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this will probably work:
    Code:
    onclick="window.open(http://link/to/your/site/);return false;)"

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    NYC
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    <td onClick="window.open('http://www.yahoo.com/','NewWindowName')">

  6. #6
    SitePoint Addict nodding dino's Avatar
    Join Date
    May 2003
    Location
    London
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks people...will give it a go!

  7. #7
    Getting there... Willigogs's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if I'm being silly (not unusual for me ), but why couldn't you simply wrap the <td> with the <A href> tag?

    Code:
    e.g.
    
    <a href="http://www.yourdomain.com" target="_blank">
    <td>
    <p>Blah Blah Blah</p>
    </td></a>
    It is certainly something I've done in the past, so PLEASE tell me if it's wrong!!!

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Willigogs
    Sorry if I'm being silly (not unusual for me ), but why couldn't you simply wrap the <td> with the <A href> tag?

    Code:
    e.g.
    
    <a href="http://www.yourdomain.com" target="_blank">
    <td>
    <p>Blah Blah Blah</p>
    </td></a>
    It is certainly something I've done in the past, so PLEASE tell me if it's wrong!!!
    That is definitely wrong. The only thing that should wrap around a table cell is a table row. This, however, will work even with Javascript turned off:
    HTML Code:
    <td>
    <a href="mypage.html" target="_blank" style="display: block; width: 100%;">A link as big as the table cell!</a>
    </td>

  9. #9
    Getting there... Willigogs's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I knew is was going to be wrong.

    It still worked though! With a little more code I was also able to add a nice rollover.

    Code:
    <a href="http://www.blahblah.com" target="_blank"> 
    <TD width="154" height="32" BGCOLOR='#21944e' onMouseOut="this.bgColor = '#21944e'" 
    onMouseOver="this.bgColor='#99cc00';this.style.cursor='hand'">Link</TD>
    </A>
    Still VERY wrong though...
    (Don't worry - I'd never employ this sort of coding anymore - it was simply the only way I could find to achieve this affect a few years ago. It was for an internal system - so I knew javascript would be enabled) - Still doesn't excuse me


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
  •