SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast sabret00the's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript help, undefined but defined function

    I've declared a function as shown in the below source snippet
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <
    html dir="ltr" lang="en">
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <!-- 
    CSS Stylesheet -->
    <
    style type="text/css">
    /* snip */
    </style>

    <!-- / 
    CSS Stylesheet -->

    <
    script type="text/javascript">
    <!--
    var 
    SESSIONURL "";
    var 
    IMGDIR_MISC "/3.5.x/forums/images/placebo_two/misc";
    var 
    vb_disable_ajax parseInt("0"10);
    // -->

    </script>

    <script type="text/javascript" src="http://localhost/3.5.x/forums/clientscript/vbulletin_global.js"></script>
    <script type="text/javascript" src="http://localhost/3.5.x/forums/clientscript/vbulletin_menu.js"></script>
    <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="external.php?type=RSS" />
    <title>my story by Funky_monkey - General Poetry - Poetry</title>
    <link rel="alternate" type="application/rss+xml" title="Creative Writing Peer Review System RSS Feed" href="misc.php?do=feed&type=rss" />
    <style type="text/javascript">
    /**
    * Opens a window to show a list of people who have this piece as their favourite (misc.php?do=whofaved&amp;PIECEID)
    *
    * @param    integer    Piece ID
    *
    * @return    window
    */
    function whofaved(pieceid)
    {
        return openWindow(
            'misc.php?' + SESSIONURL + 'do=whofaved&p=' + pieceid,
            230, 300
        );
    }
    </style>
    <style type="text/css">
    /* snip */
    </style>
    </head> 
    and here's the bit that calls the function
    PHP Code:
                        Favourites[<a href="#" onclick="whofaved(24993); return false;">who</a>] 
    however, my FF error console seems to think that whofaved is undeclared. what have i done wrong?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using a <script> tag instead of a <style> tag to include your script code.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Enthusiast sabret00the's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks that fixed it. i should've tried that before. sorry.


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
  •