I am trying to make my application compatible with all browsers and my code
ClientScript.RegisterClientScriptBlock(this.GetType(), "theAction",
"<script type='text/javascript'>
function DoSave() {
try {
document.all('" + lbnSave.ClientID + "').click();
} catch(e){}
}
</script>");
is working in IE8, Chrome and Opera, but not in Firefox. I know that document.all is IE specific, but how do I rewrite this to work in Firefox too? Many Thanks!
Use
getElementByIdwhich is cross-browser:Also, you can make your code cleaner. Fourth parameter set to
truewill add<script>tag automatically.