View Full Version : ALERT() fixs this weird problem???

08-22-2002, 03:18 PM
I have this script:

function setHtml(html){
// alert ("test");
editor100.document.body.innerHTML = "Note";

This script only works if I uncomment the alert line. If I coment that line out, I will get this error:

"editor100.document.body" is not an object.

Can someone tell me why? Why that "alert" line make the whole different?

Please help me out. I try to make the text editor just like the one in Yahoo mail. Thanks

08-22-2002, 03:35 PM
I'm guessing because the alert() causes enough of a delay for something to load that otherwise doesn't. Is editor100 a frame? Make sure all the objects you are using/calling/referencing are all loaded properly at the time setHtml() runs...

08-22-2002, 05:47 PM
editor100 is an iframe. Do you think that's why? Then what should I do to fix it?


08-22-2002, 05:53 PM
You should have the onLoad event on the body of the document withing the iFrame call up the function setHTML, because it is most likely that the body object within editor100 hasn't loaded, causing your error.

With Micsrosoft JScript you can use this:
editor100.document.body.onload = setHhtml();

But that is IE only. Don't know if there is a Moz/Gecko equivalent.

08-22-2002, 05:59 PM
Thank you. I will try them right now :)

08-22-2002, 06:22 PM
I can not get the onload function to work. So I use setTimeOut instead. But that doesn't work also. Probably becuz I am a beginner.

Here is the link, hope you can help me out when you look at the code.


When you first enter the page, there will be no error If you submit the form with an empty field, it will reload the page with the data you already entered. It saves the entered data of the editor fields in session variable, and it should load the data into the <iframe> which is used as the editor. And this is where the problem occurs.

This script I get from yahoo.

Thank you for helping me out here.

08-22-2002, 06:32 PM
I get this error

Line : 589
Char: 22
Error: Unterminated string constant.

08-22-2002, 06:46 PM
The source code will look exactly like the one you get from VIEW SOURCE within browser, plus these lines:

if Session("fContent") <> "" or Session("fNote") <> "" then
Response.Write "<script> editor.SetHTML('" + Session("fContent") + "','"+Session("fNote") + "'); </script>"
end if

between </form> and </body> and line 589 is the beginning of this script block.

It is so weird that I don't get that of error at all. I tried so many times but can not get that error.

08-23-2002, 06:55 AM
Can anyone help me out here?

08-27-2002, 07:19 PM
anyone wants to take a look at this?

08-27-2002, 07:34 PM
function setHtml(html){
editor100.document.body.innerHTML = "Note";
editor100.onload = setHhtml;