i9300
August 25, 2008, 11:46am
1
Just wondering if someone has some advice on dynamic tooltip. By that I mean, I want the text inside the tooltip to be automagically generated from a text file.
I have not included any code example because, there are tons of tooltip examples but I can't find one that will use a text file to populate the tooltip.
Thanks for any help
-Chris
i9300
September 10, 2008, 11:37am
2
In case anyone finds this useful
Here is the code that I needed.......
Place text files report_file.txt and report_file2.txt are in the same dir as html -- or path them out in the code....
<html>
<head>
<title>System Reporting</title>
<script type="text/javascript">
function showBox(file_name, id, obj) {
var helpNode = document.createElement('div'+id);
helpNode.id = 'popBox'+id;
helpNode.setAttribute('class','popBox');
var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
helpNode.appendChild(el);
el.setAttribute('src', file_name);
obj.appendChild(helpNode);
}
function hideBox(id) {
var node = document.getElementById('popBox'+id);
node.parentNode.removeChild(node);
}
</script>
<style type="text/css">
.popBox {
position: absolute;
z-index: 2;
background: #cccccc;
width: 600px;
padding: 0.3em;
border: 1px solid gray;
}
span {
color: red;
font-weight: bold;
}
iframe {
border: none;
width: 600px;
height: 200px;
}
</style>
</head>
<body>
<div onmouseover="showBox('report_file.txt', 'file1', this)"
onmouseout="hideBox('file1')"
style="cursor:pointer"><span>HOST 1</span><br/></div>
<div onmouseover="showBox('report_file2.txt', 'file2', this)"
onmouseout="hideBox('file2')"
style="cursor:pointer"><span>HOST 2</span><br/></div>
</body>
</html>