Search This Blog

Showing posts with label Tables. Show all posts
Showing posts with label Tables. Show all posts

Sunday, March 25, 2012

DIV Popup for the OnmouseOver Event


Here's neat little script that displays additional text when you mouse over a text link (or graphic). You can place the text display DIV(s) anywhere you like, or seperate them to suit your page layout
Place the following in the <head> tags.

<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>


Now set the display DIV style and positioning by placing the following in the <head> tags. Modify it to suit yourself.
<style type="text/css">#div1, #div2, #div3 {position:absolute; top: 100; left: 200; width:200; visibility:hidden}</style>
Now use the following to create the links. If you want to use them as proper links, replace # with your URLs.
<a href="#" onMouseOver="toggleDiv('div1',1)" onMouseOut="toggleDiv('div1',0)">Link 1!</a> |
<a href="#" onMouseOver="toggleDiv('div2',1)" onMouseOut="toggleDiv('div2',0)">Link 2</a> |
<a href="#" onMouseOver="toggleDiv('div3',1)" onMouseOut="toggleDiv('div3',0)">Link 3</a>

And finally add the associated text divs. You can relegate these to the bottom of the page (out of the way) if they get in the way.
<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>
<div id="div2">Link 2 text! You can add all the usual style options, and position it to suit yourself!</div>
<div id="div3">Link 3 text! Use it to explain terms or further describe your linked pages, whatever!</div>

Onmouseover Display A Box That Show Text + URL


<html>
02<head>
03<title>link box</title>
04<style>
05#messageBox{
06    border-right: 1px solid #000000;
07    position: absolute;
08    width: 217px;
09    height: 100px;
10    z-index: 1;
11    background-color: #C0C0C0;
12    border-style: solid;
13    border-width: 1px;
14    display:none;
15}
16#closeButt{
17     width: 100%;
18     height: 10px;
19     z-index: 1;
20     cursor: pointer;
21     left: 0px;
22     top: 0px;
23     background-color: #808080;
24}
25#contents{
26    width: 100%;
27    height: auto;
28    z-index: 2;
29}
30</style>
31<script language="javascript">
32function show(obj,msg){
33messageBox.style.top=obj.offsetTop
34messageBox.style.left=obj.offsetLeft+obj.offsetWidth+5
35contents.innerHTML=msg+"<p>"+obj.href
36messageBox.style.display="block"
37}
38</script>
39</head>
40
41<body>
42
43<p><a onmouseover="show(this,'this is my message#1')"href="http://www.google.com">link1: go to google</a></p>
44<p><a onmouseover="show(this,'this is my message#2')"href="http://www.msn.com">link2: go to msn</a></p>
45<p><a onmouseover="show(this,'this is my message#3')"href="http://www.dreamincode.com/">link3: go to DIC</a></p>
46
47<div id="messageBox">
48<div onclick="messageBox.style.display='none'" id="closeButt">x Click to close</div>
49<div id="contents"></div>
50</div>
51</body>
52</html>



<html>
02 
03<head>
04<script>
05function menu (whichMenu,whatState){
06if (document.getElementById)
07{document.getElementById(whichMenu).style.visibility = whatState;}
08 
09else {document[whichMenu].visibility = whatState;}
10 
11}
12function details(what){
13myInfo={"google":"the best search engin on the web","yahoo":"this is too","about":"good place to visit"}
14detailsBox.innerHTML=myInfo[what]
15}
16</script>
17</head>
18<body>
19<div id="search">
20<a onmouseover="details('google')" href="http://www.google.com/"target="_blank" class="menulink">Google</a>
21<a onmouseover="details('yahoo')" href="http://www.yahoo.com/"target="_blank" class="menulink">Yahoo!</a>
22<a onmouseover="details('about')" href="http://www.about.com/"target="_blank" class="menulink">About.com</a>
23<a href="java script://" onmouseover="menu('search','hidden')"class="menulink">CLOSE</a>
24</div>
25 
26<div id="detailsBox"></div>
27</body>
28</html>