< script language="Javascript">
<!--
function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}
//-->
< /script>
<style type="text/css">#div1, #div2, #div3 {position:absolute; top: 100; left: 200; width:200; visibility:hidden}</style>
then
<?php echo CHtml::link('Your Text',array('site/index'),
array(
'onMouseOver'=>"toggleDiv('div1',1)",
'onMouseOut'=>"toggleDiv('div1',0)",
)); ?>
<div id="div1">Link 1 text! I've restrained the div size to 200px wide in the style declaration. Modify this to suit yourself.</div>
As it is now, it just has one link named -"Your Text". In my case I have 4 links which display different message when hovered. I changed
position:relative;
to
position:absolute;
of the css file and the messages/ words of every link are now rendered on the same location of the page. My question is how to implement it so that the message/ words of the last link a user hover remains on the display area. Changing this
'onMouseOut'=>"toggleDiv('div1',0)",
to this
'onMouseOut'=>"toggleDiv('div1',1)",
does the trick but the problem is that if the user is to hover on all the links or even 2 of the links, the messages/ words of every link will pile on each other following the order in which the links have been hovered and it become unreadable. So with the value set to one, if I hover link1, the message will appear on the display location. When i remove the cursor over link1, the message will remain. Again if i hover link 2, the message of link2 will be displayed on the display location. But link1 message is still on the display are. So it means message2 piled on message1 and you cant read. Another question is how to make link1 message be on the display location by default ?