www.webdeveloper.com
Results 1 to 8 of 8

Thread: return true problem.

  1. #1
    Join Date
    Dec 2009
    Posts
    4

    return true problem.

    Two connected basic problems.

    I write:

    <a href="http://www.google.com"
    onMouseOver="window.status='some text here';
    return true">link text here</a>

    Then when the mouse is over the link the status bar just shows www.google.com. When I leave the link the "link text here" is displayed.

    This would seem to be what should happen if return true is NOT included but it is included!

    However, when I write:

    <a href="http://www.google.com"
    onMouseOver="document.bgColor='green';
    return true"><link text here</a>

    The document does indeed turn green when the mouse goes over the link.

    However, when I remove return true I get exactly the same results. AIUI the green-ness should vanish when the mouse moves off the link because there is no return true.

    Any ideas? In the first case I want to overwrite the URL in the status bar with my text when the mouse moves over the link. In the second case when I remove return true I want the screen to go back to its normal colour.

    Am I doing something wrong here? This happens in Firefox and IE. I have changed the browser settings so that Javascript can modify things like the status bar.

    Thanks.

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    I have never known a return in a onmouseover. To make things return to their original state, you have to use an onmouseout as well. Quirksmode.

  3. #3
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Sounds like a misunderstanding on the return keyword. Return sort of indicates the end-value (or data structure) of a function--it does not indicate a reversal (or "return") to the original state of anything.

    In the case of DOM events, the return statement is typically used to indicate whether the browser should process the remainder of an event chain. For instance ...
    HTML Code:
    <input type="textbox" onkeydown="doSomething(); return false;" />
    ... tells the browser NOT to display keystrokes in the box after calling doSomething(). In the absence of return true (or false), the value from doSomething() would be returned (or if doSomething() returns no value, I believe null would be "returned").

  4. #4
    Join Date
    Dec 2009
    Posts
    4
    I probably should have mentioned I am using Joe Burns' Javascript Goodies and his code shows: <A HREF="http://www.htmlgoodies.com" onMouseOver="window.status='Go to the Goodies Home Page'; return true">Click Here

    This also does not show the text when the mouse goes over the link - only after it leaves the link.

  5. #5
    Join Date
    Apr 2006
    Location
    Houston
    Posts
    1,374
    I tested this in IE7, IE8 and Firefox. All of them show the status changing when mousing over the link:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    
    </head>
    <body>
    <A HREF="http://www.htmlgoodies.com" onMouseOver="window.status='Go to the Goodies Home Page'; return true">Click Here</A>
    </body>
    </html>

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    the window status has a clear meaning: to show the address of a link. It is not indicated to change it, as the user might suspect a phishing if he does not see in the status bar what he expects to see. Anyway some browsers will not let you change the status (FF) unless a tool option is activated or changed.
    What you try to do is old fashioned and not recommended. You'd better use a title if you want to say something to the user:
    Code:
    <a gref="http://www.htmlgoodies.com" title="Go to the Goodies Home Page">Click Here</a>

  7. #7
    Join Date
    Dec 2009
    Posts
    4
    I tested this in IE7, IE8 and Firefox. All of them show the status changing when mousing over the link:
    I just copied the same link and the window.status only works when the mouse leaves the link.

    Kor: I did allow FF to change the status bar text but still it does not work.

    HTML Code:
    What you try to do is old fashioned and not recommended.
    The book is from 2002. This is too old, right. Is there a particular book for the newbie you can suggest?

    I like Joe Burns' style but don't want to spend ages learning things that are obsolete. It does not seem he has written an updated version.

  8. #8
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by zozza View Post
    I like Joe Burns' style but don't want to spend ages learning things that are obsolete. It does not seem he has written an updated version.
    It is not merely a problem of being obsolete or not. Writing messages for the user in the status bar is now useless, as you have a lot of other ways to do that. In the status bar users need to see only where a certain link goes. Period.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles