www.webdeveloper.com
Results 1 to 10 of 10

Thread: Setting functions to Events in Explorer fails.

  1. #1
    Join Date
    Nov 2008
    Posts
    116

    Setting functions to Events in Explorer fails.

    The code below is part of a tool tip set of functions. Currently this fails in Explorer as soon as it tries to set the event handlers to an instance of the functions. So in this case "initToolTipElements" is only printed once to the alert box and then the script stops. The code works fine in Firefox.

    This is the doc type to the HTML page.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    Failing function.
    Code:
    function initToolTipElements()
    {
    	var ttEls=document.getElementsByName('toolTip');
    	
    	//Looks like this is only being run once in explorer. 
    	for (i=0;i<=5;i++)
    	{
    		alert("initToolTipElements");
    		ttEls[i].onmouseover=addMapToolTip;
    		ttEls[i].onmousemove=Locate;
    		ttEls[i].onmouseout=removeToolTip;
    	}
    }
    Can any one tell me where to look for the problem?

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    what kind of elements (what tags) are those with the name="toolTip"?

    On the other hand, your javascript code is embedded or external?

  3. #3
    Join Date
    Nov 2008
    Posts
    116
    Thanks for responding. I have two tests running. One is what I'm aiming at which is an <area> tag

    Code:
    <map name="EarthMap_600_imageMap_Map" id="EarthMap_600_imageMap_Map">
         <area shape="rect" coords="70,86,95,103" href="#" alt="BritishColumbia" name="toolTip" toolTip="British Columbia"/>
    </map>
    and the other is this test that is on line.
    http://www.penproductions.ca/testToolTip.html

    When the mouse is over the blue rectangle it should pop up a simple tool tip.

    Thanks for any help that you can provide.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    First: the name attribute is not to be used upon all the HTML elements. In fact, for the modern browsers and under the last Doctype versions, there are only several elements which can bear a name (and which are to be found on using DOM getElementsByName() method. <AREA> is not one of them.

    Have you considered the use of the simple HTML attribute TITLE (no javascript code needed)?
    http://www.w3schools.com/tags/att_standard_title.asp

  5. #5
    Join Date
    Nov 2008
    Posts
    116
    Ah I see, OK so is there a getElementsByTitle function in JS? If now how would I go about collecting all the elements with a known title? Would this require a recursive function and go through all tags in the body and collect them?

  6. #6
    Join Date
    Nov 2008
    Posts
    116
    Is there no more advise on this?

  7. #7
    Join Date
    Jan 2007
    Posts
    21
    I think he's referring to this

    <Div title="this could be your tool tip">Put your mouse here</Div>

    Put that on a page and see what it does

  8. #8
    Join Date
    Nov 2008
    Posts
    116
    Thanks, I didn't know about those tool tips how ever that is not what I'm looking for in the final product. I really do need to use JS to get more data into a nicely formated popup that tracks the mouse.

    What I have works, just not in IE, so I gather that I need to find another way to collect the correct tags that will get the popups.

    What I have is a parameter in any given tag that is called toolTip="someName" and I use that property value to display the correct information.

    At the moment I'm looking at writing a recursive function that will search the page for any tab with a toolTip property. Is that the best way to go about doing that? The tag could be a div, an area, or other.

  9. #9
    Join Date
    Nov 2008
    Posts
    116
    So can you tell me why this recursive function doesn't continue. It only runs down the first branches and stops and does not continue after that.

    Code:
    function initToolTipRecursive(el)
    {
    	for (i=0;i<el.children.length;i++)
    	{
    		alert(el.children[i].tagName);
    		initToolTipRecursive(el.children[i]);
    	}
    }

  10. #10
    Join Date
    Nov 2008
    Posts
    116
    Thanks for the help, here is what I was shooting for and so far it is working on several browsers correctly. It is the map section of the site that now has nice little pop ups to display the clientele in that area.

    http://www.penproductions.ca/

    If any one sees any problems in any browser please let me know. I don't care about old browsers as any one coming to our site will be on the latest machines and software as a two year old machine is way out of date for us.

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