Results 1 to 4 of 4

Thread: right click

  1. #1
    Join Date
    Apr 2008
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default right click

    Hi people, could i havew a base code so if i left or right mouse click inside a cell it pops up a webpage?

  2. #2
    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

    This will often be blocked (security and usability settings in modern browsers), especially for the right click, but here it is:

    HTML Code:
    <td onclick="window.open('some.htm','_blank');">
    Whatever
    </td>
    You will probably have slightly more compliance in browsers if you do it like so:

    HTML Code:
    <td>
    <a href="some.htm" onclick="window.open(this.href,'_blank');return false;" 
    style="display:block;width:100%;height:100%;">Whatever</a>
    </td>
    - John
    ________________________

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

  3. #3
    Join Date
    Apr 2008
    Posts
    38
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by jscheuer1 View Post
    This will often be blocked (security and usability settings in modern browsers), especially for the right click, but here it is:

    HTML Code:
    <td onclick="window.open('some.htm','_blank');">
    Whatever
    </td>
    You will probably have slightly more compliance in browsers if you do it like so:

    HTML Code:
    <td>
    <a href="some.htm" onclick="window.open(this.href,'_blank');return false;" 
    style="display:block;width:100%;height:100%;">Whatever</a>
    </td>
    You could just use <a href="..." style="..." target="_blank">...</a> instead of
    HTML Code:
    <a href="..." onclick="window.open(this.href,'_blank');return false;" 
    style="...">...</a>
    . Plus, it is reccommended that you don't use events in attributes such as <button onclick="...">...</button>.

  4. #4
    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

    Quote Originally Posted by matthewbluewars View Post
    You could just use <a href="..." style="..." target="_blank">...</a> instead of
    HTML Code:
    <a href="..." onclick="window.open(this.href,'_blank');return false;" 
    style="...">...</a>
    . Plus, it is reccommended that you don't use events in attributes such as <button onclick="...">...</button>.

    Hmm, I'm not too big on what is 'recommended' without an explanation as to why it is recommended.

    Regardless of whether it's done my way or your way, I don't recommend doing this at all (due to its often being blocked in the manner I already outlined in my first post in this thread).

    Unless it isn't all that important that it happen -in other words the site would work fine if the page opens in the same window/tab, another window/tab, or not at all - all possibilities for any given user with any attempt like this. I would also note that your use of the target attribute is deprecated (meaning that future support is questionable), so at lest in that sense is not recommended.
    - 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
  •