homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

onload javascript -- writes textbox content into a frame
only works when I precede it with an alert()

10+ Year Member

Msg#: 300 posted 10:20 am on Mar 7, 2003 (gmt 0)

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?





10+ Year Member

Msg#: 300 posted 3:29 pm on Mar 7, 2003 (gmt 0)

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...


10+ Year Member

Msg#: 300 posted 4:50 pm on Mar 7, 2003 (gmt 0)

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.


10+ Year Member

Msg#: 300 posted 4:53 pm on Mar 7, 2003 (gmt 0)

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.



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

Msg#: 300 posted 7:58 pm on Mar 7, 2003 (gmt 0)

Or, just call the frame like this:



10+ Year Member

Msg#: 300 posted 8:12 pm on Mar 7, 2003 (gmt 0)

Hi Jpjones,
the pause just worked fine, thanx


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved