JavaScript ?

  • Thread starter Thread starter WJ
  • Start date Start date
W

WJ

How can my Asp.Net web page check to see if its client browser enables JS ?
Example: I have an Asp.Net Page that supports both Java Script and Non-Java
Script (disabled). On page_load event, I would like to redirect clients who
enable JS in their browser to different web page.

Thanks for your help,

John
 
there is a browsercapabilities class embeded in the httprequest class as a
'browser' attribute..
You can query that class for the client browser.
 
Mr. Dot Net said:
there is a browsercapabilities class embeded in the httprequest class as a
'browser' attribute..
You can query that class for the client browser.

Thanks for your reply. No it does not work. I went into my MS/IE 6.1 Sp1 and
disabled all Java scripts and applets, I also disabled Cookies. Applied the
changes. Get out of MS/IE and got backin to check the browser if these
settings are indeed persisted and they are. But my Asp.Net application still
sees they are set to "true" as indicated by the code below (unless I am
doing somethings wrong):

private void LinkButton1_Click(object sender, System.EventArgs e)
{

Label1.Text=Request.Browser.JavaScript.ToString()+":::"+Request.Browser.Java
Applets.ToString()+":::"+Request.Browser.Cookies.ToString();
}


John
 
Apparently "Mr. Dot Net" should change his name to
"Dr. Don't Have A Clue Yet" ;-) because all the BrowserCapabilities
class can tell us is if the user agent (the browser) *can* support
JavaScript not *if* JavaScript has been enabled or disabled.

Google" "javascript enabled"+"asp.net" and you'll see at least
two articles on the first page of results...

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
Dear Mr. Clinton, what a charming personality indeed.

from 4guysinrolla:

"The article Determining if your Visitors have JavaScript and Cookies
Enabled describes a method to test to see if the user has JavaScript AND
cookies enabled.

A second alternative you can use to determine if a user has cookies enabled
(as well as a slew of other options), you can use a third-party component,
like BrowserHawk. Examples on using BrowserHawk to perform Cookie checks can
be seen here. For more information on BrowserHawk be sure to read Ryan S.'s
article: Browser Detection with BrowserHawk and check out the BrowserHawk
Homepage!"
 
I have the same problem, and the only way I can think of doing this is on
every post back check for a hidden variable that is set by javascript....
....
<head><script><!--function
Loader(){document.form1.tag1.value=1;}--></script></head>
<body onload="Loader();">
<form name="form1"><input type="hidden" name="tag1" value="0"
runat="server"/></form>
....

on post back check,

tag1.value="1"

I haven't implemented in my code, thinking a better solution will present
itself but, none so far.

-Psb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top