⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax_browsers.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>AJAX Browser Support</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

</head>
<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

<h1>AJAX Browser Support</h1>
<a href="ajax_example.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="ajax_xmlhttprequest.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>
<hr />
<h2>AJAX - Browser Support</h2>
<p>The keystone of AJAX is the XMLHttpRequest 
object.</p>

<p>Different browsers use different methods to create the XMLHttpRequest object.</p>
<p>Internet Explorer uses an <b>ActiveXObject</b>, while other browsers uses the built-in JavaScript 
object called <b>XMLHttpRequest</b>.</p>
<p>To create this object, and deal with different browsers, we are going to use 
a &quot;try and catch&quot; statement. You can read 
more about the <a href="../js/js_try_catch.asp">try and catch statement</a> in our 
JavaScript tutorial.</p>
<p>Let's update our &quot;testAjax.htm&quot; file with the JavaScript that 
creates the XMLHttpRequest object:</p>

<table class="ex" width="100%" border="1" id="table5"><tr><td>
<pre>&lt;html&gt;
&lt;body&gt;</pre>
<pre>&lt;script type=&quot;text/javascript&quot;&gt;<br />function ajaxFunction()
{<br />var xmlHttp;
try
  {<br />  // Firefox, Opera 8.0+, Safari<br />  xmlHttp=new XMLHttpRequest();<br />  }
catch (e)
  {<br />  // Internet Explorer<br />  try
    {<br />    xmlHttp=new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);<br />    }
  catch (e)
    {<br />    try
      {<br />      xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);<br />      }
    catch (e)
      {<br />      alert(&quot;Your browser does not support AJAX!&quot;);<br />      return false;<br />      }<br />    }<br />  }<br />  }<br />&lt;/script&gt;</pre>
<pre>&lt;form name=&quot;myForm&quot;&gt;
Name: &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;
Time: &lt;input type=&quot;text&quot; name=&quot;time&quot; /&gt;
&lt;/form&gt;</pre>
<pre>&lt;/body&gt;
&lt;/html&gt;</pre>
</td></tr></table>
<p>Example explained: First create a variable xmlHttp<b> </b>to hold the XMLHttpRequest object.</p>
<p>Then try to create the object with XMLHttp=new XMLHttpRequest(). This is for 
the Firefox, Opera, and Safari browsers. If that fails, try xmlHttp=new 
ActiveXObject(&quot;Msxml2.XMLHTTP&quot;) which is for Internet Explorer 6.0+, if that 
also fails, try xmlHttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;) which is for Internet Explorer 5.5+</p>
<p>If none of the three methods work, the user has a very outdated browser, and 
he or she will get an alert stating that the browser doesn't 
support AJAX.</p>
<p><b>Note:</b> The browser-specific code above is long and quite complex. 
However, this is the code you can use every time you need to create an XMLHttpRequest object, so you can 
just copy and paste it whenever you need it. The code above is compatible with all the popular browsers: Internet 
Explorer, Opera, Firefox, and Safari.</p>
<p>The next chapter shows how to use the XMLHttpRequest object to communicate with 
the server.</p>
<hr />

<a href="ajax_example.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="ajax_xmlhttprequest.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -