Forum Moderators: open

Message Too Old, No Replies

Add settimeout to function for Opera 6?

Two working scripts just need to be merged...

         

JAB Creations

2:08 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've tried merging the hide function script with a settimeout but it does not seem to be working. I am testing this with Opera 6 as I'm working on legacy support plus this is a whole lot of fun!

My not working attempt...

function hidebodyDiv(divID_as_a_string) {
setTimeout("hideDiv(divID_as_a_string)",100);); {
var myReference = getRefToDiv(divID_as_a_string);
if(!myReference ) { window.alert('Nothing works in this browser'); return; }
if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
window.alert('Nothing works in this browser'); return; } }
}
}

JavaScript - Hide Function

function hideDiv(divID_as_a_string) {
var myReference = getRefToDiv(divID_as_a_string);
if(!myReference ) { window.alert('Nothing works in this browser'); return; }
if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
window.alert('Nothing works in this browser'); return; } }
}

HTML - Event

<element onEVENT="hideDiv('elementIDb1');

daveVk

3:50 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



CHANGE

setTimeout("hideDiv(divID_as_a_string)",100);); {

TO

setTimeout("hidebodyDiv('" + divID_as_a_string + "',100);" ); {

AND CHANGE

<element onEVENT="hideDiv('elementIDb1');

TO

<element onEVENT="hidebodyDiv('elementIDb1');

get rid of hidediv.

[edited by: daveVk at 3:54 am (utc) on Feb. 21, 2007]

JAB Creations

6:01 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Dave but this isn't working... :-[

- John

function hideTimedDiv(divID_as_a_string) {
setTimeout ("hideTimedDiv('" + divID_as_a_string + "',3000);"); {
var myReference = getRefToDiv(divID_as_a_string);
if(!myReference ) { window.alert('Nothing works in this browser'); return; }
if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
window.alert('Nothing works in this browser'); return; } }
}
}

daveVk

6:45 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



not sure what getRefToDiv is?

Try something like below to narrow the problem, extra code for debug only.

Where you getting any alerts?

function hideTimedDiv(divID_as_a_string) {
setTimeout ("hideTimedDiv('" + divID_as_a_string + "',3000);"); {
var myReference = getRefToDiv(divID_as_a_string);
alert( divID_as_a_string + " myReference " + ( myReference!= null ) );
if(!myReference ) { window.alert('Nothing works in this browser Case1'); return; }
if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
window.alert('Nothing works in this browser'); return; } }
}
}

What is code intended to do, seems to hide the div each time, is something else unhidding it or is the intent to toggle the visibility?