This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to call JavaScript Function from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to call JavaScript Function from jsp" Watch "How to call JavaScript Function from jsp" New topic
Author

How to call JavaScript Function from jsp

Ganesan Kaliyaperumal
Greenhorn

Joined: Jul 31, 2006
Posts: 5
Hi
I have to call a javascript function which is not defined in the jsp file.

The function "cancelButton" is defined in "xyz.js", like...

I want to call this function from "abc.jsp".
How can i call?
What are the syntaxs to call that function.

Regards
Ganesan K
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm assuming that you're not trying to call a Javascript function from JSP code. This can't be done.

Moving to the HTML/Javascript forum where Javascript issues are covered.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
In the head of the jsp, add this:
<script language="javascript" type="text/javascript" src="xyz.js"></script>

Then you can just call the function like it was included in the jsp.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Originally posted by Dom Lassy:

Then you can just call the function like it was included in the jsp.


"Like" it was included? That does include it. No "like" about it.
[ August 02, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: How to call JavaScript Function from jsp