Monday, March 26, 2012

execute function on page load

hi,

I've a javascript function that uses a webservice to fill a dropdown box. I want to call this method when my page is loaded (ie <body onload="..."> but when I do this, Atlas never finds the javascript object that represents my webservice.
I guess this is because this object gets initialized a little later. Does anyone have an idea how I could solve this?

Thanks a lot, Hannes.

Hi Hannes

You can set the load property on the atlas xml-script section to specify you javascript function to execute when the page load. For example:

<script type="text/javascript">
function onLoad(){
alert("Hello, run your code here!");
}
</script>

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<application load="onLoad">
</application>
</components>
</page>
</script>

Take a look athttp://blogs.msdn.com/jhawk/archive/2006/01/20/515590.aspx for the complete example.

thanks
-jhawk


ah, that's exactly what I was looking for. Thanks a lot, jhawk.

No comments:

Post a Comment