SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: firefox problem

  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    firefox problem

    The following code isn't working in Mozilla 5.0

    <!--
    document.write("cool baby") ;

    function myfn() {
    document.write("cool baby") ;
    }

    myfn();
    myfn();
    myfn();

    // -->

    its giving blank page...

    if i am removing the comments then it is showing the whole code...

    PLZ HELP...
    note that i am just abeginner trying to learn javascript...

  2. #2
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not entirely sure, but try something like

    Code:
    onload = function() {
     myfn();
     myfn();
     myfn();
    }

    I think just calling functions without any event won't do anything.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,834
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The problem would be because the Javascript is not inside script tags or because it is in the wrong place in the page.

    Code:
    <script type-"text/javascript">
    document.write("cool baby") ;
    
    function myfn() {
    document.write("cool baby") ;
    }
    
    myfn();
    myfn();
    myfn();
    </script>
    This code needs to go in the body of the page where you want the lines to be written.

    If the code were called after the page finished loading then the document.write statements would overwrite the whole page.

    Presumably this is on a HTML and not XHTML page since document.write can't be used with XHTML
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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