SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Great White North
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function not defined???

    Hi,

    I have the following function defined:

    Code:
    function chkCookie() {
    if (! document.cookie )
    	document.getElementById("reg").style.visibility = "visible";
    }
    which is called from an onload event in the body tag.

    I get the following error, though:

    chkCookie is not defined???

    I don't understand?

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well if that is an exact copy you are missing a } at the end

    Code:
    function chkCookie() {
    if (! document.cookie )
    	document.getElementById("reg").style.visibility = "visible";
    }
    should be:

    Code:
    function chkCookie() {
    if (! document.cookie )
    	document.getElementById("reg").style.visibility = "visible";
      }	
    }

    IF you didnt copy it wrong then make sure the path to the js file is correct (if external)

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Great White North
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dc dalton
    well if that is an exact copy you are missing a } at the end

    Code:
    function chkCookie() {
    if (! document.cookie )
    	document.getElementById("reg").style.visibility = "visible";
    }
    should be:

    Code:
    function chkCookie() {
    if (! document.cookie )
    	document.getElementById("reg").style.visibility = "visible";
      }	
    }


    IF you didnt copy it wrong then make sure the path to the js file is correct (if external)
    Hi DC.... thanks for you help.

    At the risk of sounding like a moron, I must say that I'm not sure that I follow.

    in my code:

    Code:
    function chkCookie() {
    if (! document.cookie )
    	document.getElementById("reg").style.visibility = "visible";
    }
    I have a starting curly brace and an ending curly brace... I don't see the differences in your example?

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see the differences in your example?
    No difference? His advice was incorrect, but surely you can see a difference. Since he was advising you on your braces maybe you should count the number of braces in each example.

    Post your whole page.

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Great White North
    Posts
    172
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7stud
    No difference? His advice was incorrect, but surely you can see a difference. Since he was advising you on your braces maybe you should count the number of braces in each example.

    Post your whole page.
    there are two functions in my example and three in his... I fail to see how 3 braces helps me out?

    anyways, my problem was in the script tag declaration... I labelled the mime type as text/css accidentally.

    thanks for your time.


    COB


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
  •