I have just started building this small web page and I'm getting a Javascript error I can't account for.
This is the HTML document:
nothing too mysterious there. The body tag calls the external function 'pageLoad()'
And here's the Javascript document:
as you can see, the body tag uses the 'onLoad' event to call the 'loadPage()' function, which then calls the 'loadCHSheet()' function, which then uses 'document.write ' to create an image tag with an 'onClick' event.
The image loads perfectly, but when clicked nothing happens and the javascript error box shows the error "goPage is not defined".
I changed the 'onClick' event to call an alert instead and it worked perfectly.
I'm completely stumped, please help. Thanx.
This is the HTML document:
Code:
<html> <head> <script type="text/javascript" src="scripts.js"></script> </head> <body onLoad="pageLoad()"> </body> </html>
nothing too mysterious there. The body tag calls the external function 'pageLoad()'
And here's the Javascript document:
Code:
function pageLoad()
{
loadCHSheet(); //load image
}
function loadCHSheet()
{
document.write ('<img id="sheet" src="front.bmp" onClick="goPage()">');
}
function goPage()
{
alert('test');
}
as you can see, the body tag uses the 'onLoad' event to call the 'loadPage()' function, which then calls the 'loadCHSheet()' function, which then uses 'document.write ' to create an image tag with an 'onClick' event.
The image loads perfectly, but when clicked nothing happens and the javascript error box shows the error "goPage is not defined".
I changed the 'onClick' event to call an alert instead and it worked perfectly.
I'm completely stumped, please help. Thanx.
Comment