Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

onload javascript -- writes textbox content into a frame

only works when I precede it with an alert()



10:20 am on Mar 7, 2003 (gmt 0)

10+ Year Member

This may be very simple but just could not find the solution:
I have a function called initEditor that runs on pageload that should get the value of as textbox and write it into a frame, the function looks like this:

function initEditor(){
document.frames('myEditor').tbContentElement.DOM.body.innerHTML = document.frmInsert.txtBody.value;

Somehow this does not work, but when I add an alert function before, then it works:

function initEditor(){
document.frames('myEditor').tbContentElement.DOM.body.innerHTML = document.frmInsert.txtBody.value;

Can anybody explain this to me?




3:29 pm on Mar 7, 2003 (gmt 0)

10+ Year Member

i suggest you completely move over to document.getElementByID("elementID")

and as long as those elements you are interested in have id's and/or names, you can use them. for example (im not 100% this is right)

for instance, this is how your tags might look, whereever they are:

<input type='text' id='grabThisText'>
<frame name='leftFrame'>

and in your onload function, this would be it,

document.getElementByName("leftFrame").innerHTML = document.getElementByID("grabThisText").value

now one thing: i am not going to lie to you: i never use javascript for forms, so that last part could be wrong...


4:50 pm on Mar 7, 2003 (gmt 0)

10+ Year Member

hi sethcall,

sorry but this didn't solve it I still get the same behavior. Only when I add an alertbox it writes the content of the textbox into the frame.


4:53 pm on Mar 7, 2003 (gmt 0)

10+ Year Member

Hi Pete,

It could be that your JavaScript is trying to write content before the IFrame has been set up correctly.

Putting the Alert box before the copy makes the JavaScript engine wait for the user to acknowledge - which gives the IFrame time to set up.

You could try moving the copy line to the end of the document - see if that has any effect. Either that, or
add a pause or checking routine in somewhere.



7:58 pm on Mar 7, 2003 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Or, just call the frame like this:



8:12 pm on Mar 7, 2003 (gmt 0)

10+ Year Member

Hi Jpjones,
the pause just worked fine, thanx



Featured Threads

Hot Threads This Week

Hot Threads This Month