Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reset caused by writing to <div></div> ???

Status
Not open for further replies.

Dragonfish

Programmer
Apr 25, 2001
62
UG
I`m using buttons to cause Javacript to write text (and other things) into <div id=&quot;xyz&quot;></div>

function test()
{
document.all[&quot;xyz&quot;].innerHTML = &quot;Hallo everybody&quot;;
}

This works, but immediatly after writing the text, there is a reset on the site and the text disappears. I can tell there´s a reset of some kind because there is a ticker running independently and it always restarts when function test is finished. The same thig happens when I use alerts to test access to functions:

function test()
{
alert(&quot;Function test ok.&quot;);
}

There are no JavaScript error messages. Can anybody tell me why this is happening and how to prevent it.

Thankxx
DavidinGermany
 
are u using setTimeout and objects?

if not can u post your code so we could look at it?

goodluck!!!
 
Thanks for the quick reply,

This is exactly what happens - I hope the code is´nt to long:
I´m not using timeouts. The rollover button gets it´s position from a styletag in head - works fine

<body bgcolor=&quot;#9F0000&quot; vlink=&quot;#00FF00&quot; onLoad=&quot;main()&quot;>
<DIV ID=&quot;ButtonsDiv&quot;>
<FORM>
<input type=&quot;image&quot;
style=&quot;position: absolute; border: none; top: 82px; left: 267px; width: 15pt; height: 15pt;&quot;
src=&quot;./currentimages/button1-1.gif&quot;
name=&quot;Image1&quot;
alt=&quot;Home&quot;
onclick=&quot;button('Home')&quot;
onMouseOver=&quot;MM_swapImage('Image1','','./currentimages/button1-2.gif',1)&quot;
onMouseOut=&quot;MM_swapImgRestore()&quot;>
</FORM>

<FORM>
<input type=&quot;image&quot;
style=&quot;position: absolute; border: none; top: 40px; left: 242px; width: 15pt; height: 15pt;&quot;
src=&quot;./currentimages/button2-1.gif&quot;
name=&quot;Image2&quot;
alt=&quot;1. Herren&quot;
onclick=&quot;button('Herren_eins')&quot;
onMouseOver=&quot;MM_swapImage('Image2','','./currentimages/button2-2.gif',1)&quot;
onMouseOut=&quot;MM_swapImgRestore()&quot;>
</FORM>
.
.
more buttons !!!
</DIV>

Clicking the button causes the following (external) JavaScript to write into these nested <div></div>s.

<DIV ID=&quot;MannschaftenDiv&quot;>
<DIV ID=&quot;MannschaftsBericht&quot;></DIV>
<DIV ID=&quot;Choice&quot;></DIV>
<DIV ID=&quot;TermineTabelle&quot;></DIV>
</DIV>

This is the JavaScript part. Home() is intended to empty the div area, Herren_eins() and similar functions disply the information. I have´nt bothered with the content - there´s far too much of it and it gets displayed ok - if only for an instant.

function home()
{
document.all[&quot;MannschaftsBericht&quot;].innerHTML = &quot; &quot;;
document.all[&quot;Choice&quot;].innerHTML = &quot; &quot;;
document.all[&quot;TermineTabelle&quot;].innerHTML = &quot; &quot;;
}

function Herren_eins()
{
Herren_eins_Bericht();
Herren_eins_Choice();
Herren_eins_TermineTabelle();
}

function Herren_eins_Bericht()
{
document.all[&quot;MannschaftsBericht&quot;].innerHTML = &quot;Hallo Everyone&quot;;
}

function Herren_eins_Bericht()
{
document.all[&quot;MannschaftsBericht&quot;].innerHTML = &quot;Anoter test&quot;;
}

function Herren_eins_Bericht()
{
document.all[&quot;MannschaftsBericht&quot;].innerHTML = &quot;yet another test&quot;;
}

Using an alert to test a function has the same &quot;reset&quot; effect

function Herren_eins()
{
alert(&quot;Function Herren_eins ok.&quot;);
}

Be happy to give more detail if you need it, but I think this is the core of the problem.
Thankxx alot
DavidinGermany
 
hi again!

try this:

document.getElementById(&quot;elements_id&quot;).innerHTML = &quot;blabla....&quot;

or

elements_id.innerText = &quot;blabla....&quot;

and goodluck!!!

alon.
 
Hallo Alon - is that right ???

tried it - same effect, but slower. I can put it on the web if that helps. If you let me know I´ll give you the adr.

Thankxx
DavidinGermany
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top