Results 1 to 5 of 5

Thread: whats wrong with this code?

  1. #1
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default whats wrong with this code?

    Code:
    <font color="red"> <span><OnMouseOver="this.style.color="blue"">
    hello</span>
    </font>

  2. #2
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Try this code
    Code:
    <font color="red"> <span onmouseover="this.style.color='blue';return false;" onmouseout="this.style.color='red';return false;">
    hello
    </span></font>

  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

    The font tag for one, it has been deprecated. As a result, its influence over this sort of scheme is unwelcome. In your case, possibly overriding the javascript event. Also, you have quotes within quotes in your event, this will make the browser see your event as:

    Code:
    OnMouseOver="this.style.color="
    The event should be an attribute to the span tag, not a separate tag. Camel style notation for mouse events is not required and is not forward compatible. Try:

    Code:
    <span style="color:red;" onmouseover="this.style.color='blue';">
    hello</span>
    - John
    ________________________

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

  4. #4
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ty schuer

  5. #5
    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 sandman2006
    Code:
    <font color="red"> <span onmouseover="this.style.color='blue';return false;" onmouseout="this.style.color='red';return false;">
    hello
    </span></font>
    Why cling to the deprecated font tag? Why return false? If you want to return the span to its original color on mouse out, I would do this in a style block in the head of the page or in a stylesheet linked to it:

    Code:
    span.h_over {
    color:red;
    }
    Then for the markup:

    HTML Code:
    <span class="h_over" onmouseover="this.style.color='blue';" onmouseout="this.style.color='';">hello</span>
    - 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
  •