add window.status javascript to a:hover css pseudo-class?

Discussion in 'Javascript' started by Bob P., Jun 25, 2004.

  1. Bob P.

    Bob P. Guest

    Hi, basically what I'd like to do is suppress the action that causes
    the URL to show up in the browser status bar when I roll over a
    hyperlink. I know I could use the onmouseover event in each anchor
    tag, but I'd rather be able to do it globally thru my stylesheet,
    rather than having to futz with each link. Does anyone know a
    solution for this? It seems like you could maybe add quick
    window.status='blah' javascript or something to the a:hover
    pseudoclass to control status bar behavior. Thanks.
     
    Bob P., Jun 25, 2004
    #1
    1. Advertising

  2. Bob P. wrote:
    > Hi, basically what I'd like to do is suppress the action that causes
    > the URL to show up in the browser status bar when I roll over a
    > hyperlink. [...]


    No, you don't want to mess with the UA of your visitors.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jun 25, 2004
    #2
    1. Advertising

  3. Bob P.

    Grant Wagner Guest

    "Bob P." wrote:

    > Hi, basically what I'd like to do is suppress the action that causes
    > the URL to show up in the browser status bar when I roll over a
    > hyperlink. I know I could use the onmouseover event in each anchor
    > tag, but I'd rather be able to do it globally thru my stylesheet,
    > rather than having to futz with each link. Does anyone know a
    > solution for this? It seems like you could maybe add quick
    > window.status='blah' javascript or something to the a:hover
    > pseudoclass to control status bar behavior. Thanks.


    No, you can't add Javascript to CSS, at least not in a cross-browser,
    cross-platform way (I think IE supports "behaviours" in CSS, but it's
    not supported in most other browsers).

    Use the following code to set the onmouseover event for every <A> on the
    page:

    <body onload="setAllHrefOver(returnFalse);">:
    <script type="text/javascript">
    function returnFalse() { return false; }
    function setAllHrefMOver(f, d, inLayer) {
    // to minimize page size, rather then defining separate onmouseover
    // events for every link on the page, any link without an existing
    // onmouseover event is set by this function

    if (!inLayer) {
    d = document;
    }

    if (d) {

    var i;

    if (d.links) {
    for (i = 0; i < d.links.length; i++) {
    if (!d.links.onmouseover) {
    d.links.onmouseover = f;
    }
    }
    }

    if (d.layers) {
    for (i = 0; i < d.layers.length; i++) {
    setAllHrefMOver(f, d.layers.document, true);
    }
    }
    }
    } // setAllHrefMOver()
    </script>

    It just occurred to me you could use the "d" parameter to determine if
    you're in a layer or not, you don't really need the "inLayer" indicator.
    I'm not sure why I did that way, I think I wanted to be explicit about
    when the function has been called recursively.

    Note also that this function could be modified to either be passed the
    event, or you could make a copy of the function for the onmouseout or
    other events. You can also use it to assign events to other elements at
    run-time. If you want to use it for elements other then <A>, you'll want
    to investigate whether recursing into layers is required.

    --
    | Grant Wagner <>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *
    http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

    * Internet Explorer DOM Reference available at:
    *
    http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-developer/upgrade_2.html
     
    Grant Wagner, Jun 25, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Frey
    Replies:
    0
    Views:
    411
    Kevin Frey
    Jul 28, 2006
  2. steve

    A CSS pseudo class question

    steve, Aug 25, 2005, in forum: Javascript
    Replies:
    1
    Views:
    92
  3. topmind
    Replies:
    1
    Views:
    344
    Bart Van der Donck
    Jul 1, 2006
  4. Ronen Yacov
    Replies:
    1
    Views:
    237
    David Dorward
    Nov 5, 2007
  5. Ciaran
    Replies:
    60
    Views:
    1,030
    Thomas 'PointedEars' Lahn
    Jun 29, 2010
Loading...

Share This Page