Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Javscript problem  RSS feed

 
Brian Nguyen
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am sorry to put my topic here but I think it's almost related to JSP . Here is the problem:
I define a javascript function in test.js file:
function testAlert(){
alert("testAlert");
}
In one of my html file callAlert.html, I call the function in the following:
< script src="test.js" > testAlert();
< /script >
How come that my callAlert.html doesn't pop up the alert?
Thanks,
Brian
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're wrong, sorry. Definitely a JavaScript problem
Have you tried putting the method call in its own script tags? I've never seen it done the way you are doing it...

Dave
 
LAXMI VEMARAJU
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi brian,
alreaday in your java script file, you have a method. right.
In your html file,----
< script src="test.js" > testAlert();
< /script >
---don't know weather it is right or wrong, but
as far as I know,
you need not mention the method name, instead, you just say
< script src="test.js" >< /script >
in your html file and call the method.
good luck.
lakshmi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!