Multiple onMouseOver targets...

admin

Administrator
Staff member
I think I have it mostly figured out now...thanx to everyone's help.<br />
<br />
:D <br />
<br />
Here's my final problem...<br />
<br />
Take a look at the web page at the end of this post and let me know if there's a way that I can make an ONMOUSEOVER control the text-change of the link (as it does now) AND swap pictures in the top table cell.<br />
<br />
Thanx.<br />
<br />
<!-- m --><a class="postlink" href="http://home.bendcable.com/theallensplace/">http://home.bendcable.com/theallensplace/</a><!-- m --><!--content-->This is what you need to do,<br />
in the cell where you want to display on mouseover a link,add a div tag<br />
<br />
<div id="img_div"></div><br />
<br />
then in the links where you change the color for the link<br />
<br />
replace these event calls<br />
<br />
onMouseOver="window.status='Link #1...'; return true" onMouseOut="window.status=''; return true" <br />
<br />
with this<br />
<br />
onMouseOver="window.status='Link #1...'; return true;swapImage('simein=mge.gif')" onMouseOut="window.status=''; return true;document.getElementById('img_div').style.visibility='hidden';" <br />
<br />
<br />
<br />
now in the head section of your html page add this method<br />
<br />
function swapImage(imgsrc){<br />
var obj= document.getElementById('img_div');<br />
var img = document.createElement("img");<br />
img.setAttribute("src",imgsrc);<br />
obj.appendChild(img);<br />
obj.style.visibility="visible";<br />
}<br />
<br />
this should take acare of it..<br />
<br />
:D<!--content-->Sorry 'bout this...not meaning to be a complete idiot and all, but as for div tags and the javascript...into which files shal I paste them?<br />
<br />
Also, did you realize that I'm using IFRAMES as well as tables?<br />
<br />
Thank you for your patience.<!--content-->yes you will all of the recomendational code above in the page that you load in the iframe,and ofcourse I am aware of your echnique..:-)<!--content-->Okay.<br />
<br />
I put the <div> stuff in the top (target) cell where I want the picture to show.<br />
<br />
I replaced the existing mouseovers in the nav (calling) cell.<br />
<br />
I put the javascript in the nav (calling) cell where I want the picture to show.<br />
<br />
Nothing's happening...aside from my mouseover text-change is still working.<br />
<br />
Is everything in the right place?<br />
<br />
Thanx.<!--content-->Oh yeah...<br />
<br />
And I replaced the "img" and the "src" with the name of the image.<!--content-->post a link or update the link u posted above so that I can view the changes you 've made<!--content-->Okay.<br />
<br />
I updated the site.<br />
<br />
Thanx.<!--content-->Ok here is the javascript part,I have made required changes to it.<br />
<br />
<script><br />
function swapImage(imgsrc){ <br />
var obj= parent.topFrame.document.getElementById('img_div'); <br />
var img = document.createElement("img"); <br />
img.setAttribute("src",imgsrc); <br />
obj.appendChild(img); <br />
obj.style.visibility="visible"; <br />
} <br />
<br />
function hideImage(){<br />
var obj= parent.topFrame.document.getElementById('img_div'); <br />
obj.style.visibility="hidden"; <br />
obj.innerHTML = ""<br />
}<br />
</script><br />
<br />
You must not use frame name "top"<br />
<br />
because it can confuse the page javascript engine.<br />
<br />
I have assumed the name for top frame as <br />
"topFrame"<br />
<br />
and here is the links code that will call it<br />
<br />
<a class="tap" href=http://www.webdeveloper.com/forum/archive/index.php/"b01.html" onMouseOver="swapImage('images/bw_01.jpg');window.status='Link #1...'; return true;" onMouseOut="hideImage();window.status=''; return true;" target="bod">Link #1</a><!--content-->Okay.<br />
<br />
Did I put everything where it was supposed to go?<br />
<br />
I just need to rename the frame name, right?<br />
<br />
Thanx.<!--content-->yes rename the frame name,,,<br />
aswell as use the code that I justposted<br />
<br />
just change the images/bw_01.gif to the image which u want to display<!--content-->Okay.<br />
<br />
Got everything set up just like you specified, but still, no pictures.<br />
<br />
In addition, my mouseover window.status text display isn't working anymore.<br />
<br />
Thanx.<!--content-->for the frame name<br />
<br />
parent.a.document.getElementById('img_div'); <br />
<br />
where a represents the frame name,but when I checked your code I don't see a frame name "a"?<br />
<br />
<br />
make your top frame name "a" or some other name and change the code appropriately using that name<!--content-->Sorry...I was probably still editing.<br />
<br />
Check again.<br />
<br />
Thanx.<!--content-->and for the status bar..<br />
<br />
add return false in both javascript functions at towards the very end..<br />
<br />
<br />
function swapImage(imgsrc){ <br />
var obj= parent.topFrame.document.getElementById('img_div'); <br />
var img = document.createElement("img"); <br />
img.setAttribute("src",imgsrc); <br />
obj.appendChild(img); <br />
obj.style.visibility="visible"; <br />
return true;<br />
} <br />
<br />
function hideImage(){<br />
var obj= parent.topFrame.document.getElementById('img_div'); <br />
obj.style.visibility="hidden"; <br />
obj.innerHTML = "";<br />
return true;<br />
}<!--content-->On my system using Mozilla/NS6+ browser I can see the images..how about you?<!--content-->I'm using IE 6 and can't see the images, nor will my window.status text show up.<br />
<br />
Thanx.<!--content-->I just viewed it in Netscape 7 and the pics do show up, but the window.status text doesn't and the middle cell isn't showing up either. It should fill the screen the rest of the way so that it goes like this:<br />
<br />
top<br />
<br />
nav<br />
<br />
bod<br />
bod<br />
bod<br />
bod<br />
bod<br />
bod<br />
bod<br />
<br />
bot<br />
<br />
I hate this cross-browser stuff!!!<br />
<br />
Thanx.<!--content-->Update the swap image with this code actually replace the whole function with the one below<br />
<br />
function swapImage(imgsrc){ <br />
var obj= parent.taptop.document.getElementById('img_div'); <br />
if(document.all){<br />
obj.innerHTML = "<img src=http://www.webdeveloper.com/forum/archive/index.php/\""+imgsrc+"\" alt=\""+imgsrc+"\"/>";<br />
}else{<br />
var img = document.createElement("img"); <br />
img.setAttribute("src",imgsrc); <br />
obj.appendChild(img); <br />
}<br />
obj.style.visibility="visible"; <br />
return true;<br />
} <br />
<br />
And make sure the hideImage function do not have 2 return statements..one statement return true should do it<!--content-->My bad instead of return true,use reeturn false in both function.<!--content-->AWESOME!!!<br />
<br />
YOU ARE A STAR!!!<br />
<br />
Thanx!!!<br />
<br />
Now all I need to do is figure out how to have a default image for each corresponding page that changes onmouseover and changes back onmouseout.<br />
<br />
When each specific page loads, it will have it's own corresponding graphic in the top cell. Mouseover will still change it, but mouseout will return it to the corresponding graphic for that page.<br />
<br />
Thanx again!!!<!--content-->Well...thought I could at least do that, but nope.<br />
<br />
You wouldn't happen to be able to help me with that as well, would you?<br />
<br />
:D <br />
<br />
Also, I'll need your first and last name so I can give credit to you on my site when it's complete.<br />
<br />
Thanx again.<!--content-->I sure can help you with that,if you need..:D <br />
<br />
unfortunately I am not available this evening may be later tonight or tomorrow,<br />
<br />
Khalid Ali<!--content-->Are you available?<br />
<br />
:D<!--content-->Oh yess...:<br />
:D<!--content-->Sorry 'bout the silence. Trying to learn CSS.<br />
<br />
Anyway,<br />
<br />
Can you help me with each page having it's own default image in the top cell, but still changing on mouseover and changing back on mouseout?<br />
<br />
Thanx yet again.<!--content-->I'll be able to work with you on this after an hour...talk to you then...<!--content-->
 
Back
Top