Detect if javascripting is enabled/disabled WITHOUT adding a parameter or a redirect to the current url.
All samples I have found, append a flag of some sort according the scripting being on or off. like mypage.aspx?jscript=1
I don't want that at all.
I want to check for js, write a flag to a session var and I'm guessing a client side script needs to do that via RegisterStartupScript.
If session["jsenabled"] != null, the script must have written that session var else script must be disabled...
- There is no server side code makes you know the script is enabled or not in the client browser.
- If you detect that using flag that will be set using client side and check it in the server, there is a work around telling that user may disable or enable javascript in any time, as a result it is useless to save the javascript client status.
Finally, make your validations and client side code and do not forget to make the server side validation before executing any business logic.
MCTS
If you feel it helps, Mark as answered so that it can help others to find solution.
For Any further questions, please contact me.
blmiles
Member
302 Points
92 Posts
Detecting if scripting is on/off in browser
Mar 01, 2012 04:59 PM|LINK
Yes yes, I know, loads of samples out there...
Here's one I cannot find.
Detect if javascripting is enabled/disabled WITHOUT adding a parameter or a redirect to the current url.
All samples I have found, append a flag of some sort according the scripting being on or off. like mypage.aspx?jscript=1
I don't want that at all.
I want to check for js, write a flag to a session var and I'm guessing a client side script needs to do that via RegisterStartupScript.
If session["jsenabled"] != null, the script must have written that session var else script must be disabled...
no?
no flags appended to the end of the url, none.
:-)
Muhammad Fak...
Contributor
2268 Points
511 Posts
Re: Detecting if scripting is on/off in browser
Mar 01, 2012 05:23 PM|LINK
Dear friend,
Consider the follwoing
- There is no server side code makes you know the script is enabled or not in the client browser.
- If you detect that using flag that will be set using client side and check it in the server, there is a work around telling that user may disable or enable javascript in any time, as a result it is useless to save the javascript client status.
Finally, make your validations and client side code and do not forget to make the server side validation before executing any business logic.
If you feel it helps, Mark as answered so that it can help others to find solution.
For Any further questions, please contact me.
A1ien51
All-Star
29935 Points
5821 Posts
Re: Detecting if scripting is on/off in browser
Mar 02, 2012 01:44 AM|LINK
set a hidden field with JavaScript. When the page is posted back, you can check that hidden field. If set, you know it is enabled.
Eric
Danny Gokey
Member
290 Points
56 Posts
Re: Detecting if scripting is on/off in browser
Mar 02, 2012 06:52 AM|LINK
Hi,
you can try to use the html noscript to test if the user has disabled javascript in the browser.
perhaps these articles help to u,
http://techpatterns.com/forums/about485.html
http://forums.asp.net/p/1388673/2960589.aspx
roopeshreddy
All-Star
20271 Points
3346 Posts
Re: Detecting if scripting is on/off in browser
Mar 02, 2012 09:34 AM|LINK
Hi,
You can try with <noscript> tag!
<noscript> <meta http-equiv="REFRESH" content="0;URL=http://www.xxx.com" /> </noscript>You can also consider @Alien suggestion!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
shafkatlee
Member
152 Points
53 Posts
Re: Detecting if scripting is on/off in browser
Mar 03, 2012 12:03 PM|LINK
Hi,
Try this code:
function hideScriptDisabled() { document.getElementById("scriptDisabled").display = "none"; } <p id="scriptDisabled">You have JavaScript disabled, <a href="#">click here</a>.</p> <script type="text/javascript">hideScriptDisabled();</script>blmiles
Member
302 Points
92 Posts
Re: Detecting if scripting is on/off in browser
Mar 04, 2012 12:35 AM|LINK
Thanks all of you. I like the hidden field idea, will try all though...
Thanks again