Apr 12 2008

JavaScript Utility Methods added by ScriptManager

Category:Bil@l @ 21:00

I was checking the JavaScript generated on an ASP.NET page when a ScriptManager control is added. I noticed several handy JavaScript methods that you can use seamlessly inside your <script /> blocks on the page with even worrying about the browser the code is executed in.

The following JavaScript functions are cross-browser and included by default on the page when the ScriptManager control is placed:

function WebForm_GetScrollX() {}
function WebForm_GetScrollY() {}
function WebForm_RemoveClassName(element, className) {}
function WebForm_GetElementById(elementId) {}
function WebForm_GetElementByTagName(element, tagName) {}
function WebForm_GetElementsByTagName(element, tagName) {}
function WebForm_GetElementDir(element) {}
function WebForm_GetElementPosition(element) {}
function WebForm_GetParentByTagName(element, tagName) {}
function WebForm_SetElementHeight(element, height) {}
function WebForm_SetElementWidth(element, width) {}
function WebForm_SetElementX(element, x) {}
function WebForm_SetElementY(element, y) {}


No need to go through the above functions. They are clear and very handy and above all cross-browser!!


Enjoy them.



Comments are closed