导读:
使用JS调用xmlHttp读取远端文件,
实现不刷新网页更新内容,
如果用户浏览器是IE的话,我们习惯使用下面的方式:
var xmlDom = new ActiveXObject("Microsoft.XMLHTTP");
var strData = "code=123";
xmlDom.open("POST", "default.asp",false);
xmlDom.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlDom.send(strData);
但,如果客户端是FireFox,这段代码就不能使用了
因为FireFox不支持:ActiveXObject
在FireFox中,必须使用下面的方式才行:
new XMLHttpRequest()
其实针对IE,有人也会使用:
new ActiveXObject("Msxml2.XMLHTTP")
不过这就要看客户端浏览器支持的xmlHttp是什么版本了。
所以为了让大多数浏览器都可以使用,
一般的想法是现判断浏览器的种类,然后建立相应的对象,
不过查看Google的源码,
他用了更巧妙的 try/catch 方法:
function jb() {
var A=false;
try {
A=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
A=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc) {
A=false;
}
}
if ( !A &&typeof XMLHttpRequest != "undefined" ) {
A=new XMLHttpRequest();
}
return A;
}
这样,在使用时,只要这样调用就可以了:
var xmlDom = jb();
var strData = "code=123";
xmlDom.open("POST", "default.asp", false);
xmlDom.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlDom.send(strData);
[Last Modified By todd, at 2005-07-20 13:08:48]
Comments Feed:http://www.todd-lee.com/blog/feed.asp?q=comment&id=63
本文转自
http://www.todd-lee.com/blog/article.asp?id=63
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/abigfrog/archive/2007/10/19/1831956.aspx
分享到:
相关推荐
jsp\No result defined for action and result input.doc
利用clipboard.js,复制文本或者隐藏域到剪切板,没有flash限制,兼容ie.chrome.firefox
RF and Digital Signal Processing for Software-Defined Radio: A Multi-Standard Multi-Mode Approach by Tony J. Rouphael RF and Digital Signal Processing for Software-Defined Radio: A Multi-...
to present signal processing principles used in the software defined radio, ranging from analog ,digital modulation to RF, DSP and data conversion.
Firefox, google, the object encapsulates the ajax Compact Framework, can be directly used in embedded projects Description: For more on the extended period for repair ajax upload some bug, add user-...
Software-defined radios (SDRs) have been around for more than a decade. The first complete Global Positioning System (GPS) implementation was described by Dennis Akos in 1997. Since then several ...
Software Defined Radio Architectures, Systems and Functions
非ie内核浏览器ACTIVEX插件+火狐谷歌支持OBJECT
3G软件无线电software defined radio for 3G,很不错,可惜是英文的,
linux ls find 时大于2G文件时出现Value too large for defined data type 系统本身支持大于2G文件但查询有问题的解决办法
No result defined for action.doc
Software_Defined_Radio_using_MATLAB_Simulink_and_the_RTL-SDR第三章中文翻译版
软件无线电,Simulink 文档类型:电子书 页数:674 2015年新书
Further areas of exploration include: distributions defined in terms of the multivariate normal, chi-square, t, and F (central and non-central); the one- and two-sample Wilcoxon test, together with ...
Big Data and Software Defined Networks 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书...
解析ScrollPic在ie8下只滚动一遍,然后变为空白(ie6,ie7,chrome,firefox都正常)
中文译名《软件无线电中的射频与数字信号处理》,不可多得的一部实用的软件无线电著作,可以当作手册,供工程人员参考借鉴。
Learn to:Control storage costs,Eliminate storage bottlenecks,Use IBM GPFS to solve storage management challenges
Data clustering is a common technique for statistical data analysis, which is used in many fields, including machine learning, data mining, pattern recognition, image analysis and bioinformatics. ...
R for Everyone: Advanced Analytics and Graphics (Addison-Wesley Data & Analytics Series) by Jared P. Lander English | 14 Jun. 2017 | ASIN: B071X9KT1D | 560 Pages | AZW3 | 58.72 MB Statistical ...