Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ALERT() fixs this weird problem???

    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

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    editor100 is an iframe. Do you think that's why? Then what should I do to fix it?

    Thanks

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you. I will try them right now

  • #6
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get this error

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

  • #8
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #9
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can anyone help me out here?

  • #10
    New Coder
    Join Date
    Aug 2002
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone wants to take a look at this?

  • #11
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    <script>
    function setHtml(html){
    editor100.document.body.innerHTML = "Note";
    }
    editor100.onload = setHhtml;
    </script>
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •