Solved

Checking browser capabilities

Posted on 2010-08-22
9
621 Views
Last Modified: 2012-05-10
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
Comment
Question by:calypsoworld
  • 4
  • 2
  • 2
  • +1
9 Comments
 

Expert Comment

by:fsouzabrasilrj
Comment Utility
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
Use Java to do the redirect leaving a message if it doesn't work.
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
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
 

Author Comment

by:calypsoworld
Comment Utility
> sybe

Ok, but how to do these tests?
Thanks!
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 28

Accepted Solution

by:
sybe earned 250 total points
Comment Utility
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
 

Author Comment

by:calypsoworld
Comment Utility
> 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
 

Author Comment

by:calypsoworld
Comment Utility
Help, please.
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
Comment Utility
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
 

Author Closing Comment

by:calypsoworld
Comment Utility
Thank you!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now