JavaScript
  Home arrow JavaScript arrow Page 4 - Detect Browser Compatibility with the Requ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Detect Browser Compatibility with the Request Object
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-07-17

    Table of Contents:
  • Detect Browser Compatibility with the Request Object
  • Using a Function for Checking Compatibility
  • Ajax Basics
  • Ajax Basics continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Detect Browser Compatibility with the Request Object - Ajax Basics continued


    (Page 4 of 4 )

    Here’s an example of an entire compatibility check:

      /* Wrapper function for constructing a request object.
      
    Parameters:
        reqType: The HTTP request type, such as GET or POST.
        url: The URL of the server program.
        asynch: Whether to send the request asynchronously or not. */

      function httpRequest(reqType,url,asynch){
          //Mozilla-based browsers
          if(window.XMLHttpRequest){
             
    request = new XMLHttpRequest();
         
    } else if (window.ActiveXObject){
              request=new ActiveXObject("Msxml2.XMLHTTP");
              if (! request){
                 
    request=new ActiveXObject("Microsoft.XMLHTTP");
             
    }
          }
          //the request could still be null if neither ActiveXObject
          //initialization succeeded
          if(request){
             
    initReq(reqType,url,asynch);
          } else {
              alert("Your browser does not permit the use of all "+
                    "of this application's features!");
          }
      }
     /* Initialize a request object that is already constructed */
      function initReq(reqType,url,bool){
          /* Specify the function that will handle the HTTP response */ 
      request.onreadystatechange=handleResponse;
          request.open(reqType,url,bool);
          request.send(null); 
      
    }

    “Use the Request Object to POST Data to the Server” [Hack #2] shows how to implement a POST request withXMLHttpRequest.  


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Ajax Hacks," published by O'Reilly. We...
       · Why go through all the work.. I think the approach that JAK uses to discover...
     

    Buy this book now. This article is excerpted from the book Ajax Hacks, written by Bruce W. Perry (O'Reilly; ISBN: 0596101694). Check it out today at your favorite bookstore. Buy this book now.

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT