473,396 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

innerHTML?

Hi all,

I'm new to javascript, so please be gentle. :-) I have a "tooltip"
script that I found somewhere, and I want to add html tags, links, etc.
to the tooltip window. I already use a couple of tooltip.js type files
in other sites, but I'm trying to learn. I'm assuming that it involves
innerHTML? Here's the html with the script, and thanks for any
info/advice.

PlainDave

<html>
<head>
<title>
Bible Fellowship Events Calendar - printable version
</title>

<style type="text/css">
<!--
BODY {
color: #000;
background-color: #fff;
font-family: Tahoma, Helvetica, Sans Serif;
text-align: left;
margin-left: 2px;
margin-right: 2px;
}
li {
background-color: #fff;
color: #000;
font-family: Tahoma, Helvetica, Sans Serif;
font-size:13px;
font-weight:normal;
text-align:left;
margin-bottom:9px;
margin-left:-14px;
line-height:109%;
list-style-position: inside;
list-style-type: disc;
}
..nonmonth {
background-color: #fff;
height=100px;
width:14%;
text-align:right;
vertical-align:top;
color: #ddd;
font-family: Tahoma, Helvetica, Sans Serif;
font-size:17px;
font-weight:bold;
}
..datenumber {
background-color: #fff;
color: #000;
height=100px;
width:14%;
text-align:right;
vertical-align:top;
font-family: Tahoma, Helvetica, Sans Serif;
font-size:17px;
font-weight:bold;
}
..events {
background-color: #fff;
color: #000;
font-family: Tahoma, Helvetica, Sans Serif;
font-size:13px;
font-weight:normal;
text-align:left;
}
div.events {
float:left;
margin-left:-23px;
width:155;
height:2;
}
table.cal {
width:100%;
cellpadding:3;
cellspacing:0;
border:1px solid black;
border-collapse: collapse;
background-color: #fff;
}
td {
border:1px solid black;
background-color: #fff;
}
td.weekday {
background-color: #fff;
color: #000;
font:17px Tahoma, Helvetica, Sans Serif;
width:14%;
text-align:center;
vertical-align:middle;
font-weight:normal;
padding: 2px 0 2px
}
/*
tr {
height=100px;
}
*/
li.youth {
background-color: #fff;
color: #000;
font-family: Tahoma, Helvetica, Sans Serif;
font-size:13px;
font-weight:normal;
text-align:left;
}
..menu {
font: 9px Tahoma, Helvetica, Sans Serif;
color: #000;
background-color: #fff;
padding:2px;
vertical-align: middle;
text-align:left;
text-decoration:none;
height:1px;
width:10px;
cursor:help;
border: 1px solid #c30;
}
..tip {
color: #000;
background-color: #fff;
height=1px;
text-decoration:underline;
}
..toolTip {
color:#000;
background-color: #dff1ff;
border-top: 1px solid #ddd;
border-right: 2px solid #000;
border-bottom: 2px solid #000;
border-left: 1px solid #ddd;
text-align: left;
font-weight:normal;
position: absolute;
padding: 6px;
font-family:Georgia,Verdana,Arial,Helvetica,sans serif;
font-size:80%;
font-variant:normal;
width: 250px;
text-decoration : none;
}
..more {
cursor:hand;
color:blue;
}
div.questions {
color:#03f;
background-color:white;
float:left;
margin: -21, 5px;
font: normal normal normal 10px Tahoma;
text-align: right;
font-face:Tahoma, Arial, Helvetica;
letter-spacing:0.2em;
text-decoration:none;
}
a, a:link {
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
-->
</style>

<!-- START OF TOOLTIP JAVASCRIPT -->
<script type="text/javascript">

// The tool tip is created and referenced as a global object.
var tipDiv;
function genToolTip()
{
if (document.createElement) {
tipDiv = document.createElement('div');
document.body.appendChild(tipDiv);
tipDiv.appendChild(document.createTextNode('initia l text'));
tipDiv.className = 'toolTip';
tipDiv.style.display = 'none';
}
}

window.onload = genToolTip;

function showTip(e, txt)
{
if ( tipDiv ) {
var e = e || window.event;
var xy = cursorPos(e);
tipDiv.firstChild.data = txt;
tipDiv.style.left = (xy[0] + 15) + 'px';
tipDiv.style.top = (xy[1] + 3) + 'px';
tipDiv.style.display = '';
}
}

function hideTip()
{
if ( tipDiv ) {
tipDiv.style.display = 'none';
}
}

// Based on quirskmode 'get cursor position' script
function cursorPos(e){
if (e.pageX || e.pageY) {
return [ e.pageX, e.pageY ];
} else if (e.clientX || e.clientY) {
return [
e.clientX + document.body.scrollLeft,
e.clientY + document.body.scrollTop
];
}
}
</script>
<!-- END OF TOOLTIP JAVASCRIPT -->

</head>
<body>

<div class="events">
<ul>
<li>Thursday night Men's Bible Study has been cancelled until sometime
in January. We'll keep you posted.
<a onmouseover="showTip(event,'Thursday night Men\'s Bible Study has
been cancelled temporarily and will resume sometime in January. We\'ll
keep you posted. If you have any questions, feel free to email Dave
(Dave\'s email address can be found at the bottom of this page).')"
onmouseout="setTimeout('hideTip()', 100);"><span
class="more"><u>More...</u></span></a>
</li>
</ul>
</div>
</body>
</html>

Dec 9 '05 #1
2 1682
Try changing

tipDiv.firstChild.data = txt;

to

tipDiv.innerHTML = txt;

Dec 9 '05 #2
Thanks! That's exactly what I was looking for. It works great! Now, if
only I can find the time to learn some javascript. The possibilities
seem endless.

PlainDave

Dec 10 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris | last post by:
How can I get the innerHTML of a <div> area only when the page loads, then use that variable in a function? Here is my code: function setContent(zz) { var lb =...
7
by: KK | last post by:
Please help! I am currently experiencing a bug in Safari v125.9. When I modify the value of form input box and then get the innerHTML property of the surrounding div object - I am returned the...
6
by: Andrew Poulos | last post by:
Given that I need to be able to add a TYPE attribute when I'm using createElement and it seems to fail in both IE and FF (but not MZ) is it 'safer' to use innerHTML instead? I can dynamically...
4
by: RobG | last post by:
I know you aren't supposed to use innerHTML to mess with table structure, but it seems you can't use it just after a table without damaging the containing element. I added a table to a div using...
9
by: Hallvard B Furuseth | last post by:
Why does the FAQ (Q 4.15) recommend innerHTML when so many here say one should use createElement(), replaceChild() etc? Also, why does the "Alternative DynWrite function" at...
2
by: sveinn | last post by:
Hi all, I've read through this group searching for an answear about this problem. Few have come close but not quite what I need. My problem is this: I'm using Ajax to fetch a new table with...
17
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works...
9
by: martymix | last post by:
simple question: I have a simple <dt>test text</dt> I get the innerHTML of that dt, and I try and append some text to it like so: dt = document.getElementsByTagName('dt') var text =...
6
by: PaPa | last post by:
I'm not sure this is a javascript issue or an HTML issue. I notice that when I extract the contents of a div using the innerHTML property (?), that I wind up with a literal variable (?) which...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.