PDA

View Full Version : problems calling second function


jasonrg
03-20-2003, 06:20 PM
I've got a bit of a question and was hoping you could help. I'm using a javascript function to build an html page using document.write() When I try to include a call to another function, it doesn't work. Any suggestion? Thanks!

JasonRG

<html>
<head>
<script language="JavaScript"
function example()
{
this.document.write('<a href="javascript:showMessage()">Click here</a>')
}
function showMessage()
{
alert("Here")
}
</script>
</head>
<body onload="example()">
</body>
</html>

Borgtex
03-20-2003, 06:36 PM
I think that <body onload="example()"> will replace the page with the result of the function. Try

<body>
<script>example()</script>
...

<body>

instead

Philip M
03-20-2003, 06:39 PM
Missing > after

<script language="JavaScript"

should be

<script language="JavaScript">

jasonrg
03-20-2003, 06:48 PM
Originally posted by Borgtex
I think that <body onload="example()"> will replace the page with the result of the function. Try

<body>
<script>example()</script>
...

<body>

instead

That fixed it!! Thanks!!!!