Mouseover changing text and graphic

Busy's picture

He has: 6,151 posts

Joined: May 2001

I can get this to work in IE5 and NN4.7 but not NN6, the image swap is ok, just the text swap wont work.
both are done by mouseover, but I've only included the text part below, what i have is:

<script type="text/JavaScript">
<!--
function findObj(n, d) {
  var p,i,x; 
  if(!d) d=document;
  if(!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  return x;
}

function TextOfLayer(objName,x,newText) {
  if ((obj=findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape') {
    document.write(unescape(newText)); document.close();
    } else innerHTML = unescape(newText);
}
//-->
&lt;/script&gt;
'
in the head and the body section contains:
<!-- this text is what changes -->
<div id="lyrDescription" style="position:absolute;
left:290px; top:340px; width:200px; z-index:2">Default text here.</div>

<!-- this is the image that it all runs off -->
<a href="link.html"
onMouseOver="TextOfLayer('lyrDescription','',mouseover text goes here')"
onMouseOut="TextOfLayer('lyrDescription','','second default text here.')">
<img src="image.gif" width="138" height="29" border="0" alt="imagename"></a>
'
I made the link above several lines as this page was to wide

This is all the coding involved, no other div's are used, just more mouseover images.
As a last resort I could do the text in an image but would be nice not too, any ideas? I've been playing with this so long am now running around in circles.
Sorry I dont have it uploaded to show what its doing

Busy's picture

He has: 6,151 posts

Joined: May 2001

I found a script that works in ie5, Net4.7 and Net6 but works via a textera box that I cant resize the same to all 3 browsers Sad even incasing it in a table with a fixed width wouldnt work

http://www.simplythebest.net/info/javascript32.html

is the script, but their copy and paste code is wrong and missing the end part (i copy and pasted from their source code).

Can someone with Ie6 test that script please (they have a working demo), mac users to please

z28cam's picture

They have: 102 posts

Joined: Oct 2001

Works fine in IE6

Busy's picture

He has: 6,151 posts

Joined: May 2001

Thanks Z28cam,

I got the sizing sorted but has the blank scroll bar in some and not others, also cant change the font, some are able to be read only, some arent ....
So I think I've spent to much time working on this gimick, am going to do it with two images.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.