PDA

View Full Version : Javascript help, undefined but defined function


sabret00the
02-09-2007, 09:54 AM
I've declared a function as shown in the below source snippet
<!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" id="vbulletin_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="EBS:L!VE Forums RSS Feed" href="external.php?type=RSS" />
<meta name="Copyright" content="Copyright sabret00the (c)2005" />
<title>my story by Funky_monkey - General Poetry - Poetry - EBS:L!VE Creative</title>
<link rel="alternate" type="application/rss+xml" title="EBS:L!VE 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)
*
* @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
Favourites: 1 [<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?

Adrian Schneider
02-09-2007, 01:33 PM
<style type="text/javascript"> should be <script type="text/javascript">

Analogpoint
02-09-2007, 04:02 PM
And of course th closing tag too, lest it be forgotten.

</style> => </script>

sabret00the
02-09-2007, 04:54 PM
thanks folks. that was a silly one, i feel embarrassed.

Analogpoint
02-09-2007, 05:05 PM
Don't worry about it, it happens to the best of us! :)