Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
35
rated 0 times [  42] [ 7]  / answers: 1 / hits: 20654  / 14 Years ago, fri, june 4, 2010, 12:00:00

I have two pages one is the main page and the another one is the inner page:



Page names: main.jsp , sidebar.jsp
I want to call the onload function on both of these pages. Is that possible. If yes How?



Below is the code for main.jsp:



    <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ include file=/pages/common/init.jsp%>

<%@ taglib prefix=sx uri=/struts-dojo-tags%>

<html xmlns=http://www.w3.org/1999/xhtml lang=en xml:lang=en>
<head>
<title>J.C. Taylor - Broker Website</title>
<meta http-equiv=content-type content=text/html;charset=utf-8 />
<link rel=stylesheet href=/css/default.css media=screen type=text/css />
</head>
<body onload=prepopulateFields();load(17);>

<s:form name=continue id=continue_id action=continue method=POST validate=true enctype=multipart/form-data>
<div id=wrapper>
<div id=main>
<div id=sidebar>
<%@ include file=/pages/common/sidebar.jsp%>
<span class=clearIt></span>
</div>


The sidebar.jsp is:



<body onload=setSelected();>
//Some static content here
</body>


So Basically I want is to call prepopulateFields() Javascript method which belongs to onload() event of the main .jsp page and setSelected() which belongs to onload() method of the sidebar.jsp symulatneously and separately.



I know I can call the setSelected(); method inside the prepopulateFields() method but that I dont want to do. All I want is when the page is loaded both the onload functions should be called separately.



If you have some suggestions please do let me know!
I know I am being little bit ridiculous here but if I could do that My job will be very easy.


More From » html

 Answers
28

i don't think you can call more than one onload function.
best way is to call the method from already called function



function prepopulateFields(){
if //condition which check the current page where you want other onload function
setSelected();
}

<body onload=prepopulateFields();load(17);>



</body>

[#96581] Wednesday, June 2, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nikhilc

Total Points: 128
Total Questions: 100
Total Answers: 89

Location: Mali
Member since Sat, Feb 12, 2022
2 Years ago
;