Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Apr 2003
    Posts
    8
    Member #
    1029
    I'm very new (read: "have no idea") to JavaScript. There is an effect I want to create where clicking anywhere on the background of a cell acts as a link, replacing the current page with a new one. The script I have so far looks a bit like this:

    <table width="100% height="50">
    <tr>
    <td class="bar" width="100%" height="50" bgcolor="red" onmouseover="this.style.backgroundColor='red'; this.style.color='green';" onmouseout="this.style.backgroundColor='green'; this.style.color='red';" onmousedown="????? .load('newpage.html');">
    New page
    </td>
    </tr>
    </table>

    Where the question marks are I've tried page, window, document etc. Can it be done this way? If so, what is the object called? If not, any (simple) suggestions?

    Thanks!

    Matt.

  2.  

  3. #2
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    [minicode]window.location.src = 'newpage.html';[/minicode]?
    JR

  4. #3
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    Originally posted by JR
    [minicode]window.location.src = 'newpage.html';[/minicode]?
    Correction:
    [minicode] window.location.href = 'newpage.html'; [/minicode]
    - Brian

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    lol... i don't know what you guys are doing... but here's what you do. Replace this:
    Code:
    onmousedown="????? .load('newpage.html');"
    with this:
    Code:
    onclick="window.location.href = 'newpage.html';"
    The reason you use "onclick" is so that it executes when they release the mouse button. Onmousedown will execute when they press the mouse button, which isn't normal mouse behavior, and can be confusing.

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    BTW.... by the "you guys" I meant JR and skrlin w/ the funky [code tags]

  7. #6
    Junior Member
    Join Date
    Apr 2003
    Posts
    8
    Member #
    1029
    Thanks!

    Thanks everyone. A little bit of CSS and the buttons work a treat! (Settled with transio's code by the way!). Check the site out if you want (please don't laugh: it's my first attempt!)...

    www.nigelbirrell.com

    By the time you get this post I should have updated it. If not, sorry!

    Thanks again.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:58 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com