• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 632
  • Last Modified:

Checking browser capabilities

Hi!

I have a page in my website that requires Cookies, Java Applets (JRE) and JavaScript.

I tried System.Web.HttpBrowserCapabilities browser = Request.Browser; and only if all requeriments are fulfilled, the browser redirects to the page. But even with Java disabled, the page is redirected.

            System.Web.HttpBrowserCapabilities browser = Request.Browser;

            if (browser.JavaApplets)
            {

                if (browser.Cookies)
                {

                    if (browser.EcmaScriptVersion.Major > 1)
                    {
                        Response.Redirect("~/mypage.aspx");
                    }
                    else
                    {
                        Label1.Text += "No JavaScript.";
                    }
                }
                else
                {
                    Label1.Text += "No Cookies.";
                }
            }
            else
            {
                Label1.Text += "No Java.";
            }

Open in new window


How can I check all these requirements?

Thanks in advance!
0
calypsoworld
Asked:
calypsoworld
  • 4
  • 2
  • 2
  • +1
2 Solutions
 
fsouzabrasilrjCommented:
0
 
Dave BaldwinFixer of ProblemsCommented:
Use Java to do the redirect leaving a message if it doesn't work.
0
 
sybeCommented:
That is because your code only checks for what a browser *could* support, based on the browser application name. Your code does not test for what the browser actually supports.

If you want to check for javascript, then you use some javascript to see if that works.
If you want to check if java (applets) will works, then you need to have a java-applet in the page and see if that works.
etc.

In other words: check for what the browser actually does, and not what it could theoretically do.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
calypsoworldAuthor Commented:
> sybe

Ok, but how to do these tests?
Thanks!
0
 
sybeCommented:
this is sort of the simplest:

<script>document.write('your browser supports javascript');</script>
<noscript>your browser does <b>not</b> support javascript</noscript>

for redirecting you could use:
<script>document.location='javascriptsupported.aspx';</script>

With support for java-applets you can do the same: write an applet that will redirect the browser. If the browser is redirected, java-applets are working, if not, then the browser does not support java-applets.

0
 
calypsoworldAuthor Commented:
> sybe

Thank you very much!

What about the cookies verification? Is it possible to check if cookies are enabled on client's browser?
In my solution, I should verify all three capabilities (javascript, applets e cookies).
May I group these validations in one single page? (Like cascate ifs - all conditions passed: okpage.aspx - at least one condition failed: errorpage.aspx)

Thank you!
0
 
calypsoworldAuthor Commented:
Help, please.
0
 
Dave BaldwinFixer of ProblemsCommented:
Cookies are set and get only on the page request.  If you set a cookie on this page request, you have to wait until the next page request to check it or use javascript/AJAX to send the info back to your server page.

You can check them all on one page.  Set a cookie on the initial page request.  Use the javascript and noscript tags together.  The noscript section puts up a message that users see if the javascript is not enabled.  If the javascript runs then you could use the javascript to check the cookie and put up a message about the Java Applet. Then use the javascript to load the Java Applet.  I think.  The last stage, the Java Applet can then report back to you and do the redirect to the next page.
0
 
calypsoworldAuthor Commented:
Thank you!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now