many times we might
require to call some functions on body onload event. As web part does
not contain body tag we cannot use onload attribute of body tag.
To overcome this drawback, a developer can use an array i.e. _spBodyOnLoadFunctionNames
The only thing we need to do is to pass the function's name using .push method.
Example:
<script language="javascript">
_spBodyOnLoadFunctionNames.push("TestFunction");
function TestFunction()
{
alert("hello");
}
</script>
We can use above script in master page, aspx page, content editor web part, visual web part as per the need.
To overcome this drawback, a developer can use an array i.e. _spBodyOnLoadFunctionNames
The only thing we need to do is to pass the function's name using .push method.
Example:
<script language="javascript">
_spBodyOnLoadFunctionNames.push("TestFunction");
function TestFunction()
{
alert("hello");
}
</script>
We can use above script in master page, aspx page, content editor web part, visual web part as per the need.
No comments:
Post a Comment