cancel
Showing results for 
Search instead for 
Did you mean: 

BODY Onload

Former Member
0 Kudos

In JSP of the JSPDynpage component, how to auto load a function??How can achieve the functionality that we could normally get thru <body onload="alert('Hello SAP!')"></body>

Can anyone please tell me how equivalent the below to regular html tags??

<hbj:content id="myContext" >

<hbj:page title="PageTitle">

<hbj:form id="myFormId" >

</hbj:form>

</hbj:page>

</hbj:content>

Thanx for all Inputs!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Peter,

In JSPdynpage u can use HTML and javascript as it is.

Regards

gEorgE

Former Member
0 Kudos

Thanx for all Inputs.

Jacob,Do you mean i can write <body onload="abc()"> tag in JSP and it loads and executes the function First before all other stuff??

Thanx

Former Member
0 Kudos

Hi Peter,

onLoad will be the first command to be executed after your whole .jsp has loaded.

Regards,

Ville

darrell_merryweather
Active Contributor
0 Kudos

Peter

I don't think that this is going to work. The main reason is that using the JspDynpages (and AbstractPortalComponents) there is some Javascript that already captures the onload event. Also, code that generates the HTML for the component already puts a BODY tag into the output.

Therefore you would have to do something like this

<script language="JavaScript">

function hello(){

alert('hello');

}

window.onload=hello;

</script>

and this will override the standard onload method

I hope this helps

Darrell

Answers (2)

Answers (2)

former_member1
Active Participant
0 Kudos

Hi Peter,

You can use the following piece of code:

<script language="javascript">
function abc()
{
   alert("Hi");
}
</script>
<body onload=abc()>

Thanx & Regards

Anish

Former Member
0 Kudos

Hi Peter,

If you want your function to be executed before your whole document is loaded then best place for your script is between header tags <head></head>.

Regards,

Ville

darrell_merryweather
Active Contributor
0 Kudos

Peter (and everyone else)

I created a simply little test component and your can't use the <body onload="myfunction()"> because of the reasons that I mentioned in my previous post. When doing this nothing happens, unless this is different in NW04, but for SP2 this definately doesn't work. This is why the window.onload=myfunction definately works

D

Former Member
0 Kudos

Thanx for all Inputs,

Darrell,

I've tried window.onload=myfunction but itz not working for me. I know <body> tag has no effect. Iam on SP12 of portal.

How do we control JSP to load a function first and then the rest??

can we sue something like this??

<hbj:content>

<hbj:document>

<hbj:document body>

</hbj:document body>

<hbj:form>

</hbj:form>

</hbj:document>

</hbj:content>

I have seen the above code on SDN..

Thanx.

darrell_merryweather
Active Contributor
0 Kudos

The code that I used in the JSP page was: -

<html>

<head>

<script language="JavaScript">

function message(){

alert('hello');

}

window.onload=message

</script>

</head>

<body>

This is the body

</body>

</html>

and this worked fine for me

I hope this helps

D

Former Member
0 Kudos

Hi Peter

Even this would work

<script language="javascript">
alert("Hellp SAP!");
</script>

Regards

Pran