jsp页面兼容谷歌浏览器相关问题

(1)js按键事件兼容:function document.oncontextmenu() ie8可运行,谷歌改为function document.onkeydown()

(2)触发事件对象:IE浏览器支持window.event.srcElement,谷歌火狐支持window.event.target;兼容时做一下三目运算即可window.event.srcElement?window.event.srcElement:window.event.target

(3)style对象的cssText方法:ie8:obj.runtimeStyle.cssText ;谷歌:obj.runtimeStyle.cssText

(4)函数定义方式:function document.onclick() {}在谷歌浏览器内不支持,改为document.onclick = function (){}

(5)document.writeln:谷歌浏览器使用时需要添加name属性 document.writeln('<iframe id=endDateLayer name=endDateLayer frameborder=0 ></iframe>');

window.frames.endDateLayer.document.writeln(strFrame);

(6)document.all在IE、可以使用,谷歌浏览器不支持,所有以document.all.*方法获取对象的地方都改为document.getElementById或document.getElementsByName或document.getElementsByTagName。

(7)时间选择:对于简单的时间选择,可以将原有的弹框获取时间的方式改为WdatePicker, 例:<input type="text" onFocus="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})" class="Wdate"/>

(8)window.showModalDialog 兼容,在谷歌浏览器中可通过 window.open实现,

if (window.showModalDialog == undefined) {

ret = window.open(url + param, "", "width=345px,height=700px");

} else {

ret = window.showModalDialog(url + param, "", 'dialogWidth:345px;dialogHeight:700px;center:1');

return ret;

}

(9) 对于打开子窗口需要往父页面传值,可在父页面js打开子窗口时设置定时器检测子窗口是否关闭。

父页面设置定时器判断子窗口是否关闭:

winTimer=window.setInterval(function(){

if(ret.closed){

console.log(ret)

if(top.frames[0][1].returnValue !==undefined){

ret = top.frames[0][1].returnValue

return ret;

} else if (top.frames[0][0].returnValue !==undefined){

ret = top.frames[0][0].returnValue

return ret;

}

window.clearInterval(winTimer);  

}

},500);

子窗口回值:

if (window.showModalDialog == undefined) {

parent.window.opener.returnValue = group_id + "$" + group_name ;

 } else{

window.returnValue = group_id + "$" + group_name ;

 }

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值