SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OnClick in TR conflicting with A Onclick

    Hi all,

    Simple little problem - I have the following sample code and when I click the a href link it pops up both windows.

    Code HTML4Strict:
    <tr onclick="window.open('thislink.html','thiswindow',config='height=600,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no');return false;" style="cursor:pointer">
        <td>Some data</td>
        <td>More date</td>
        <td><a href="thatlink.html" onclick="window.open(this.href,'thatwindow',config='height=600,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no');return false;">Details</a></td>
    </tr>
    In other words - linking the link that should open up 'thatlink.html' opens up that window first followed by the 'thislink.html' window in the table row onclick call.

    Thoughts and ideas appreciated

  2. #2
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do you have an onclick on the row? I've never done that before. Usually the onclick is on a hyperlink or button. How does this page work?

    I'm not sure how you would get around this because the anchor is contained within the row. Could you provide a third column with a small icon or something for the row click to fire off of?

  3. #3
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your td click event is bubbling up to the tr element. Different browsers let you stop bubbling in different ways.
    Try looking up cancelBubble and stopPropagation

  4. #4
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that


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
  •