Script For Detecting Availability of XMLHttp in Internet Explorer

Posted by Duncan Mills on Oracle Blogs See other posts from Oracle Blogs or by Duncan Mills
Published on Sat, 08 May 2010 19:13:30 -0800 Indexed on 2010/05/10 17:26 UTC
Read the original article Hit count: 352

Filed under:
|
|
|
|
Having the XMLHttpRequest API available is key to any ADF Faces Rich Client application. Unfortunately, it is possible for users to switch off this option in Internet Explorer as a Security setting. Without XMLHttpRequest available, your ADF Faces application will simply not work correctly, but rather than giving the user a bad user experience wouldn't it be nicer to tell them that they need to make some changes in order to use the application? 
Thanks to Blake Sullivan in the ADF Faces team we now have a little script that can do just this.
The script is available from https://samplecode.oracle.com here - The attached file browserCheck.js is what you'll need to add to your project.
The best way to use this script is to make changes to whatever template you are using for the entry points to your application. If you're not currently using template then you'll have to make the same change in each of your JSPX pages.
  1. Save the browserCheck.js file into a /js/ directory under your HTML root within your UI project (e.g. ViewController)
  2. In the template or page, select the <af:document> object in the Structure window.
  3. From the right mouse (context) menu choose Facet and select the metaContainer facet.
  4. Switch to the source code view and locate the metaContainer facet. Then insert the following lines (I've included the facet tag for clarity but you'll already have that):
      <f:facet name="metaContainer">
        <af:resource type="javascript"
                     source="/js/browserCheck.js"/>
        <af:resource type="javascript">
           xmlhttpNativeCheck(
                     "help/howToConfigureYourBrowser.html");
        </af:resource>
      </f:facet>

Note that the argument to the xmlhttpNativeCheck function is a page that you want to show to the user if they need to change their browser configuration. So build this page in the appropriate place as well. You can also just call the function without any arguments e.g. xmlhttpNativeCheck(); in which case it will pop up default instructions for the user to follow, but not redirect to any other page.

© Oracle Blogs or respective owner

Related posts about adf

Related posts about ui