...

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



dominicosavio
08-22-2002, 02: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

beetle
08-22-2002, 02: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...

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

Thanks

beetle
08-22-2002, 04: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.

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

dominicosavio
08-22-2002, 05: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.

http://www.tntt.org/thieunhi/cms/chia_se.asp

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.

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

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

dominicosavio
08-22-2002, 05: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.

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

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

joh6nn
08-27-2002, 06:34 PM
<script>
function setHtml(html){
editor100.document.body.innerHTML = "Note";
}
editor100.onload = setHhtml;
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum