dmurray
10-12-2002, 10:11 PM
I am placing variable content, triggered by a rollover, into one of 3 <div> tags that have overlapping positions on the display. My first attempts appeared to work OK. I was simply using innerHTML = "" to clear the old <div> content. However, when a form with <input> elements was placed in one <div1>, the <div2> "under" the input tag would interfere (no cursor response) with form elements. This interference was at the left boundary of the interfering <div2>.
I then decided to create and then remove the <div> element as follows:
// Div one
function makeTopics() {
if(typeof(d_topic)!="undefined"){document.body.removeChild(d_topic)}
if(typeof(d_section)!="undefined"){document.body.removeChild(d_section)}
if(typeof(d_content)!="undefined"){document.body.removeChild(d_content)}
var d_topic = document.createElement("<div class='topic' id='d_topic' name='d_topic'>");
document.body.insertBefore(d_topic);
document.getElementById('d_topic').innerHTML=topic;
}
// Div two
function swapContent(n) {
if (typeof(d_content)!="undefined"){document.body.removeChild(d_content);}
var d_content = document.createElement("<div class='content' id='d_content' name='d_content'>");
document.insertBefore(d_content);
document.getElementById('d_content').innerHTML=content[n];
}
// Div three
function swapSection(section) {
if(typeof(d_section)!="undefined"){document.body.removeChild(d_section)}
if(typeof(d_content)!="undefined"){document.body.removeChild(d_content)}
if(typeof(d_topic)!="undefined"){document.body.removeChild(d_topic)}
var d_section = document.createElement("<div class='section' id='d_section' name='d_section'>");
document.body.insertBefore(d_section);
document.getElementById('d_section').innerHTML=section;
What happens is:
makeTopic() <-> makeTopic() :1 or more rollover OK
swapSection() <-> swapSection :1 or more rollover OK
makeTopic() <-> swapSection() : Alternating rollover OK
swapSection <-> makeTopic() : Alternating rollover OK
makeTopic()<->makeTopic()->swapSection() : Fails
swapSection<->swapSection()->makeTopic() : Fails
The error message I get is "Object doesn't support this property or method".
If I remove the removeChild code from the script, I don't get the error but the old contents isn't removed either.
Any Thoughts
Thanks
I then decided to create and then remove the <div> element as follows:
// Div one
function makeTopics() {
if(typeof(d_topic)!="undefined"){document.body.removeChild(d_topic)}
if(typeof(d_section)!="undefined"){document.body.removeChild(d_section)}
if(typeof(d_content)!="undefined"){document.body.removeChild(d_content)}
var d_topic = document.createElement("<div class='topic' id='d_topic' name='d_topic'>");
document.body.insertBefore(d_topic);
document.getElementById('d_topic').innerHTML=topic;
}
// Div two
function swapContent(n) {
if (typeof(d_content)!="undefined"){document.body.removeChild(d_content);}
var d_content = document.createElement("<div class='content' id='d_content' name='d_content'>");
document.insertBefore(d_content);
document.getElementById('d_content').innerHTML=content[n];
}
// Div three
function swapSection(section) {
if(typeof(d_section)!="undefined"){document.body.removeChild(d_section)}
if(typeof(d_content)!="undefined"){document.body.removeChild(d_content)}
if(typeof(d_topic)!="undefined"){document.body.removeChild(d_topic)}
var d_section = document.createElement("<div class='section' id='d_section' name='d_section'>");
document.body.insertBefore(d_section);
document.getElementById('d_section').innerHTML=section;
What happens is:
makeTopic() <-> makeTopic() :1 or more rollover OK
swapSection() <-> swapSection :1 or more rollover OK
makeTopic() <-> swapSection() : Alternating rollover OK
swapSection <-> makeTopic() : Alternating rollover OK
makeTopic()<->makeTopic()->swapSection() : Fails
swapSection<->swapSection()->makeTopic() : Fails
The error message I get is "Object doesn't support this property or method".
If I remove the removeChild code from the script, I don't get the error but the old contents isn't removed either.
Any Thoughts
Thanks