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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS document.writeln problem

    Hello,

    I have a simple question, but I can't find a answer to it.
    In the index.php there is a javascript:

    PHP Code:
     //document.writeln(<input type="button" name="submit" value="Submit">); 
    and this JS is disabled, is there any way to call this JS in that page?

    Thank you, for your help

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Firstly, avoid document.write(ln). It's old, old, old. Create an HTML element (span or div or something), give it an ID, and use innerHTML (or jQuery .html()) to populate it after it's created.

    Secondly, the // at the beginning of the line is commenting out that line. Remove that, and the line should be enabled. But, again, refer to my "Firstly" comment.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    Firstly, avoid document.write(ln). It's old, old, old. Create an HTML element (span or div or something), give it an ID, and use innerHTML (or jQuery .html()) to populate it after it's created.

    Secondly, the // at the beginning of the line is commenting out that line. Remove that, and the line should be enabled. But, again, refer to my "Firstly" comment.
    I know that it's a old way to do it.

    But, I want to execute that Javascript remotely through my browser, without removing comment lines. Is that possible?

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    If the double-slash is preceeding it, no. It's commented out, the browser does not parse it.

    If you need to set it so that it triggers on a button click or link click, place that inside a function and call the function using onclick="" attribute. But, then, that brings us back to the "Firstly" comment. document.write and document.writeln both will rewrite the whole page if executed after the page loads.

    http://stackoverflow.com/questions/5...fter-page-load
    Last edited by WolfShade; 03-08-2013 at 03:10 PM.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


  •  

    Posting Permissions

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