Mozilla vs IE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SGN Craig

    #1

    Mozilla vs IE

    I'm a new to Javascript. My code works in IE but not in Mozilla. I'd like
    the page to work in both. I looked around on the web but couldn't find any
    site that explained how to do this:

    <SCRIPT LANGUAGE="javas cript">
    function highlightButton (s)
    {
    if ("A"==event.src Element.tagName )
    event.srcElemen t.className=s;
    }
    </SCRIPT>
    ...
    ...
    <span onMouseover="hi ghlightButton(' dynalinkH')"
    onMouseout="hig hlightButton('d ynalink')">

    Now, I'm trying to change the tags CSS from dynalink to dynalinkH when the
    mouse is moved over the tag. From research online I know that I need to
    somehow pass the event into my function for mozilla to work. But I can't
    find an example and don't know how to do it.

    Could someone give me a simple example on how to use events in my function
    with mozilla?

    Thanks for any assistance.

    - C




    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.510 / Virus Database: 307 - Release Date: 7/25/2003




    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
  • Lasse Reichstein Nielsen

    #2
    Re: Mozilla vs IE

    "SGN Craig" <NO.SPAM.c0de3@ yahoo.com> writes:
    [color=blue]
    > Could someone give me a simple example on how to use events in my function
    > with mozilla?[/color]

    <script type="text/javascript">
    function highlightButton (s,evt) {
    var tgt = evt.target || evt.srcElement; // Correct or IE
    if (tgt.tagName == "A") {
    tgt.className=" s";
    }
    }
    </script>

    <span onmouseover="hi ghlightButton(' dynalinkH',even t);"
    onmouseout="hig hlightButton('d ynalink',event) ;">


    You problem is that IE doesn't pass events as other browsers, and
    instead has a global variable called "event". You try to access that
    global variable, and ofcourse it only works in IE.

    Also, IE uses the property "srcElement " for the object that triggered
    the event, where the DOM standard uses "target".

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...