var leftPos = (typeof window .screenLeft == 'number' ) ? window .screenLeft : window .screenX;
var topPos = (type window .screenTop == 'number' ) ? window .screenTop : window .screenY;
var blocked = false ;
try {
var tip = window .open("http://www.baidu.com" , "_blank" );
if (tip == null ){
blocked = true ;
}
} catch (ex) {
blocked = true ;
}
if (blocked){
alert('窗口被阻止了' );
}
var BrowserInfo = {
userAgent: navigator.userAgent .toLowerCase ()
isAndroid: Boolean(navigator.userAgent .match (/android/ig)),
isIphone: Boolean(navigator.userAgent .match (/iphone|ipod/ig)),
isIpad: Boolean(navigator.userAgent .match (/ipad/ig)),
isWeixin: Boolean(navigator.userAgent .match (/MicroMessenger/ig)),
}
function strLength (str) {
var a = 0 ;
for (var i = 0 ; i < str.length; i++) {
if (str.charCodeAt(i) > 255 )
a += 2 ;
else
a++;
}
return a;
}
function GetQueryStringRegExp (name,url) {
var reg = new RegExp ("(^|\?|&)" + name + "=([^&]*)(\s|&|$)" , "i" );
if (reg.test(url)) return decodeURIComponent (RegExp .$2. replace(/+/g , " " )); return "" ;
}
var tmp = window .open("about:blank" , "" , "fullscreen=1" )
tmp.moveTo(0 , 0 );
tmp.resizeTo(screen.width + 20 , screen.height);
tmp.focus();
tmp.location.href = '//www.che168.com/pinggu/eva_' + msgResult.message[0 ] + '.html' ;
var config_ = "left=0,top=0,width=" + (window .screen.Width) + ",height=" + (window .screen.Height);
window .open('//www.che168.com/pinggu/eva_' + msgResult.message[0 ] + '.html' , "winHanle" , config_);
// 模拟form提交打开新页面
var f = document .createElement("form" );
f.setAttribute('action' , '//www.che168.com/pinggu/eva_' + msgResult.message[0 ] + '.html' );
f.target = '_blank' ;
document .body.appendChild(f);
f.submit();
判断是否是 IE 浏览器
if (document .all){
alert(”IE浏览器”);
}else {
alert(”非IE浏览器”);
}
if (!!window .ActiveXObject){
alert(”IE浏览器”);
}else {
alert(”非IE浏览器”);
}
判断是IE几
var isIE=!!window .ActiveXObject;
var isIE6=isIE&&!window .XMLHttpRequest;
var isIE8=isIE&&!!document .documentMode;
var isIE7=isIE&&!isIE6&&!isIE8;
if (isIE){
if (isIE6){
alert(”ie6″);
}else if (isIE8){
alert(”ie8″);
}else if (isIE7){
alert(”ie7″);
}
}
function getOs () {
if (navigator.userAgent.indexOf("MSIE 8.0" ) > 0 ) {
return "MSIE8" ;
}
else if (navigator.userAgent.indexOf("MSIE 6.0" ) > 0 ) {
return "MSIE6" ;
}
else if (navigator.userAgent.indexOf("MSIE 7.0" ) > 0 ) {
return "MSIE7" ;
}
else if (isFirefox = navigator.userAgent.indexOf("Firefox" ) > 0 ) {
return "Firefox" ;
}
if (navigator.userAgent.indexOf("Chrome" ) > 0 ) {
return "Chrome" ;
}
else {
return "Other" ;
}
}
JS判断两个日期大小 适合 2012-09-09 与2012-9-9 两种格式的对比
function ValidateDate () {
var beginDate = $("#t_datestart" ).val();
var endDate = $("#t_dateend" ).val();
if (beginDate.length > 0 && endDate.length>0 ) {
var sDate = new Date (beginDate.replace(/-/g , "/" ));
var eDate= new Date (endDate.replace(/-/g , "/" ));
if (sDate > eDate) {
alert('开始日期要小于结束日期' );
return false ;
}
}
}
$( "id" ).onkeypress = function (event ) {
event = (event ) ? event : ((window .event ) ? window .event : "" )
keyCode = event .keyCode ? event .keyCode : (event .which ? event .which : event .charCode);
if (keyCode == 13 ) {
$( "SubmitLogin" ).onclick();
}
}
C.ajax = function (args) {
var self = this;
this.options = {
type: 'GET' ,
async: true ,
contentType: 'application/x-www-form-urlencoded' ,
url: 'about:blank' ,
data: null ,
success: {},
error: {}
};
this.getXmlHttp = function () {
var xmlHttp;
try {
xmlhttp = new XMLHttpRequest();
}
catch (e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP" );
}
catch (e) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP" );
}
}
if (!xmlhttp) {
alert('您的浏览器不支持AJAX' );
return false ;
}
return xmlhttp;
};
this.send = function () {
C.each(self .options, function (key, val) {
self .options[key] = (args[key] == null ) ? val : args[key];
});
var xmlHttp = new self .getXmlHttp();
if (self .options.type.toUpperCase() == 'GET' ) {
xmlHttp.open(self .options.type, self .options.url + (self .options.data == null ? "" : ((/[?]$/.test(self .options.url) ? '&' : '?' ) + self .options.data)), self .options.async);
}
else {
xmlHttp.open(self .options.type, self .options.url, self .options.async);
xmlHttp.setRequestHeader('Content-Length' , self .options.data.length);
}
xmlHttp.setRequestHeader('Content-Type' , self .options.contentType);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 ) {
if (xmlHttp.status == 200 || xmlHttp.status == 0 ) {
if (typeof self .options.success == 'function' ) self .options.success(xmlHttp.responseText);
xmlHttp = null ;
}
else {
if (typeof self .options.error == 'function' ) self .options.error('Server Status: ' + xmlHttp.status);
}
}
};
xmlHttp.send(self .options.type.toUpperCase() == 'POST' ? self .options.data.toString() : null );
};
this.send();
};
function CreateFrom(url, params) {
var f = document.createElement ("form" )
f.setAttribute ("action" , url)
for (var i = 0
var input = document.createElement ("input" )
input.setAttribute ("type" , "hidden" )
input.setAttribute ("name" , params[i].paramName )
input.setAttribute ("value" , params[i].paramValue )
f.appendChild (input)
}
f.target = "_blank"
document.body .appendChild (f)
f.submit ()
}