Solved

Call javascript from jsp

Posted on 2007-11-15
3
5,369 Views
Last Modified: 2008-02-01
Hello Everyone,

I have a jsp page which acts as a template in the main page, the jsp page does not have any body tags,I want to call a javascript function within this jsp page whenever the page is loaded or refreshed. Usually in a html body tag you could call it in the onLoad event, how would i call it without the body tag.

Thank you
Harsha
0
Comment
Question by:gbvreddy
  • 2
3 Comments
 
LVL 27

Expert Comment

by:rrz
ID: 20292682
What does the javascript do ?  
>how would i call it without the body tag.  
Doesn't the JSP output ultimately end up in the body tag of the enclosing page ?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 20297330
You could try just sticking the javascript at the bottom of your template...  Then the full DOM won't have finished loading, but at least this part of it will have...

<div>

  <%= "Woo! I'm a JSP with no body" %>

</div>

<script type="text/javascript">

  alert( 'and I'm some javascript' );

</script>

Open in new window

0
 
LVL 35

Expert Comment

by:TimYates
ID: 20297333
(obviously, you should use valid javascript with no escaping errors like mine)

*blush*
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
using web browser with BING 40 89
HTML page and JavaScript 2 55
Create a new template 9 21
Problem to page 4 27
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now