How can I execute Javascript function before Page load? How can I execute Javascript function before Page load? asp.net asp.net

How can I execute Javascript function before Page load?


Without thinking too hard about the direction you're trying to go in, there is a little used tag that is supported by all browsers called NOSCRIPT.

<noscript><img src="http://myserver/notify_no_script.aspx" style="display:none"></noscript>

As you can see, the idea is to make the browser request an image but only if javascript is disabled. This page could set a session variable stating that the current client has no script capability that would be available to all code in the current session.

Or, you could follow your current methodology:

<noscript><input type="hidden" name="noscript" value="1"></noscript><script><!--document.writeline('<input type="hidden" name="noscript" value="0">');//--></script>

Hope this helps,

-Oisin


you should draw your script or noscript header as a page onto itself that then redirects (either through a meta tag or through a script location.href) to the next place you want to go based on if javascript is turned on. It'll take 2 steps, but it'll get you the result you're looking for. You can pass the information you need back to yourself in the query of the redirect.


javascript can set cookie by itself.

var myDate = new Date()document.cookie = 'IJE=1; expires=' + myDate.toGMTString()

Does this resolve your problem?