Click to See Complete Forum and Search --> : create a div and Iframe dynamically and then loosing functionality of user control


Sava
05-09-2006, 02:55 PM
:confused: I have webpage with drop down lists, so I use a div and Iframe to display my calendar (user control, code in Javascript).
when I place the html code directly on the page I can click on the calendar, open mode, and change the months.

When I use "Page.RegisterStartupScript("Startup", String)
" and the script says "document.write ..."
I can't do that anymore, the calendar control collapses as soon as I click and won't change the months, it will change the date in my connceted textbox, but that's it.
I have no idea what causes this effect and really need to fix it.
I am brand new to javascript and the code for the control is copy paste work.
Any help is much appreciated

Ultimater
05-09-2006, 04:34 PM
document.write("hi<br>there"); executed as the page is loading can be replaced with any one of the following upon a user-actived event:

document.body.innerHTML+="hi<br>there";

I recall this reloading the whole page though. You might be better off setting-up a blank DIV and adding your innerHTML to the DIV to save the rest of the page from reloading. Do note that innerHTML is still non-standard but is highly supported on most modern browsers.

Another approach which is the standard approach but rather lengthy:

document.body.appendChild(document.createTextNode("hi"));
document.body.appendChild(document.createElement("br"));
document.body.appendChild(document.createTextNode("there"));



Then there is always firstChild.data in place of innerHTML etc. You'd best use innerHTML for now.

There are plenty of other ways to simulate the same effect but aren't cross-browser or are poorly supported. A poorly supported example:

document.body.insertAdjacentHTML("beforeEnd","hi<br>there")