sincilite
10-20-2006, 07:21 AM
I've been playing around with the script below which, when you rollover the span with the class of jargon, a little expanation of the keyword will be shown with in the span (class=explanation).
My problem is I cannot get the "explanation" span to appear in the same position x-browser. If anyone can see where the problem lies it would be much appreciated.
Thanks
Mike
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo date("d/m/Y") . " " . date("H.i:s"); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="javascript" type="text/javascript">
function jargon() {
//LOAD SPANS
var spans=document.getElementsByTagName("span");
for(var i=0; i<spans.length; i++) {
//DOES SPAN HAVE CLASS
if(spans[i].className=="jargon") {
//GET CHILDNODES
var explanation=spans[i].childNodes;
spans[i].onmouseover=function() {
for(var x=0; x<explanation.length; x++) {
//SPAN HAS CLASS
if(explanation[x].className=="explanation") {
//SHOW IT
explanation[x].onmouseover=explanation[x].style.display="block";
}
}
}
spans[i].onmouseout=function() {
for(var x=0; x<explanation.length; x++) {
if(explanation[x].className=="explanation") {
explanation[x].onmouseout=explanation[x].style.display="none";
}
}
}
}
}
}
function loadfunctions() {
jargon();
}
//LOAD FUNCTIONS
window.onload=function() { loadfunctions(); }
</script>
<style type="text/css">
<!--
body
{
margin: 0px;
padding: 0px;
background-color: #fff;
background-image: url(ZZZZmike/pageImages/bg_menu.gif);
background-position: 10px 10px;
background-repeat: repeat-x;
font-family: "Trebuchet MS", arial, sans-serif;
color: #acacac;
font-size: 70%;
}
div#control
{
width: 690px;
margin: 10px 0px 0px 0px;
border-left: 10px solid #fff;
}
span.jargon {
cursor: pointer;
position: relative;
display: inline;
}
span.explanation {
marin: 0px;
padding: 0px;
width: auto;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='bg_mike.png');
color: #fff;
border: 1px solid #7ba952;
padding: 20px;
position: absolute;
display: none
}
span.explanation[class] {
background: transparent url("bg_mike.png") repeat top left;
}
-->
</style>
</head>
<body>
<div id="control">
<p>This is some text with a <span class="jargon">keyword<span class="explanation">This is the explanation of jargon.</span></span> within it.</p>
</div>
</body>
</html>
My problem is I cannot get the "explanation" span to appear in the same position x-browser. If anyone can see where the problem lies it would be much appreciated.
Thanks
Mike
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo date("d/m/Y") . " " . date("H.i:s"); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="javascript" type="text/javascript">
function jargon() {
//LOAD SPANS
var spans=document.getElementsByTagName("span");
for(var i=0; i<spans.length; i++) {
//DOES SPAN HAVE CLASS
if(spans[i].className=="jargon") {
//GET CHILDNODES
var explanation=spans[i].childNodes;
spans[i].onmouseover=function() {
for(var x=0; x<explanation.length; x++) {
//SPAN HAS CLASS
if(explanation[x].className=="explanation") {
//SHOW IT
explanation[x].onmouseover=explanation[x].style.display="block";
}
}
}
spans[i].onmouseout=function() {
for(var x=0; x<explanation.length; x++) {
if(explanation[x].className=="explanation") {
explanation[x].onmouseout=explanation[x].style.display="none";
}
}
}
}
}
}
function loadfunctions() {
jargon();
}
//LOAD FUNCTIONS
window.onload=function() { loadfunctions(); }
</script>
<style type="text/css">
<!--
body
{
margin: 0px;
padding: 0px;
background-color: #fff;
background-image: url(ZZZZmike/pageImages/bg_menu.gif);
background-position: 10px 10px;
background-repeat: repeat-x;
font-family: "Trebuchet MS", arial, sans-serif;
color: #acacac;
font-size: 70%;
}
div#control
{
width: 690px;
margin: 10px 0px 0px 0px;
border-left: 10px solid #fff;
}
span.jargon {
cursor: pointer;
position: relative;
display: inline;
}
span.explanation {
marin: 0px;
padding: 0px;
width: auto;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='bg_mike.png');
color: #fff;
border: 1px solid #7ba952;
padding: 20px;
position: absolute;
display: none
}
span.explanation[class] {
background: transparent url("bg_mike.png") repeat top left;
}
-->
</style>
</head>
<body>
<div id="control">
<p>This is some text with a <span class="jargon">keyword<span class="explanation">This is the explanation of jargon.</span></span> within it.</p>
</div>
</body>
</html>