浏览器兼容性

来源:互联网 发布:c语言接口与实现 编码 编辑:程序博客网 时间:2024/05/19 13:26
一、模态窗体
1、模态窗体的关闭调用函数closeModalDialog(retValue),这个函数在util.js里
2、要取得返回值,打开模态窗体后要加一句话,如下:
  var ret = window.showModalDialog(url, window, WindowStyle);
  if (ret == undefined){
    ret = window.returnValue;
  }
3、chrome浏览器下,需要从模态窗体获取值的(如选择用户)
原来是 window.returnValue = retValue+"||"+retName;
要改成
if (window.opener != undefined){
    if (window.opener.document.all("<%=request.getParameter("userID")%>") != undefined)
      window.opener.document.all("<%=request.getParameter("userID")%>").value=retValue;
    if (window.opener.document.all("<%=request.getParameter("userName")%>") != undefined)
      window.opener.document.all("<%=request.getParameter("userName")%>").value=retName;
}else{
    window.returnValue = retValue+"||"+retName;
}


二、JS到服务器端取值(必须IE7.0以上)
原来写法是:var httpob = new ActiveXObject('Microsoft.XMLHTTP');  或者 var httpob = new ActiveXObject("Microsoft.XMLHTTP");
或者 var httpob=new ActiveXObject('Microsoft.XMLHTTP');
httpob.Open
要改成  - var httpob = new XMLHttpRequest();
httpob.open


三、列表复选框选择,这些复选框都是只有name,没有id的
原来写法是:document.Form1.item(n)
要改成 document.getElementsByName(n)[0]


四、打开窗体大小,包括卡片变动、详情等地方
原来写法是:
var ChildWin=window.open(url,"","width="+screen.width+",height="+screen.height+",top=50,left=50,scrollbars=yes,resizable=yes");
ChildWin.resizeTo(screen.availWidth-100,screen.availHeight-100);
ChildWin.moveTo(50,50);
在有些浏览器下无法获取screen.availWidth,会导致打开的窗体很小
要改成
var width=1000;
var height=750;
if (screen.availWidth > 0){
width=screen.availWidth-100;
}else if (screen.width > 0){
width=screen.width-100;
}
if (screen.availHeight > 0){
height=screen.availHeight-100;
}else if (screen.height > 0){
height=screen.height-100;
}

var ChildWin=window.open(url,"","width="+width+",height="+height+",top=50,left=50,scrollbars=yes,resizable=yes");




坚决不发:


new String(request.getParameter("HCMC").getBytes("ISO-8859-1"),"UTF-8");   
<!DOCTYPE html><!--STATUS OK--><html><head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">

用到ajax的地方 有那份txt下载


<script language="JavaScript" src="../../pub/WdatePicker/WdatePicker.js"></script>
<script language="javaScript" src="../pub/js/util.js"></script>
onclick="closeWindow()"


openUserTree


+"&userID="+userID+"&userName="+userName;




删除范例:
<script language="javaScript" src="../../pub/js/util.js"></script>
if (window.opener != undefined) {
   window.opener.Form1.submit();
   window.close();
}else{
closeModalDialog("2");
}

function btn_close(){
if(window.opener != undefined) {
   window.opener.Form1.submit();
   window.close();
}else{
closeModalDialog("2");
}
}

function sucClose(){
if (window.opener != undefined) {
alert("aa");
var pagesize=document.getElementById("pagesize").value;
window.opener.Form1.action="ListPage_sysjf.jsp?wid=&active=2&tp=ZC_BMNDJC&curpage=1&pagesize="+pagesize;
   window.opener.Form1.submit();
   window.close();
}else{
alert("bb");
closeModalDialog("2");
}
}


function backList(){
window.close();
parent.left.xtggcx_query();
}


IE刷新页面
document.Form1.action = "#";
document.Form1.submit();


<script type="text/javascript">
function confirm_zcfl(){
var lbbh=document.getElementById("LBBH").value;
if(lbbh.indexOf(";")!=-1){
lbbh = lbbh.substring(0,lbbh.indexOf(";"));
}
if (myBrowser() == "Chrome"){
   if (window.parent.opener.document.getElementById("LBBH") != undefined)
     window.parent.opener.document.getElementById("LBBH").value=lbbh;
   window.parent.close();
}else{
closeModalDialog(lbbh);
}
}
function close_zcfl(){
if (myBrowser()== "Chrome") {
   window.parent.close();
}else{
window.close();
}
}
</script>




<script type="text/javascript">
function confirm_sfl(){
var lbbh=document.getElementById("LBBH").value;
var lbbhmc=document.getElementById("LBBHMC").value;
if(lbbh.indexOf(";")!=-1){
lbbh1 = lbbh.substring(0,lbbh.indexOf(";"));
}
if(lbbh.indexOf(";")!=-1){
lbbhmc = lbbh.substring(lbbh1.length+1);
}
if(lbbh.indexOf(";")!=-1){
lbbhmc = lbbhmc.substring(0,lbbhmc.indexOf(";"));
}
if (myBrowser() == "Chrome"){
   if (window.parent.opener.document.getElementById("XYBH") != undefined){
      window.parent.opener.document.getElementById("XYBH").value=lbbh1;
   }
   if (window.parent.opener.document.getElementById("MC") != undefined){
       window.parent.opener.document.getElementById("MC").value=lbbhmc;
   }
   window.parent.close();
}else{
closeModalDialog(lbbh);
}
}
function close_sfl(){
if (myBrowser()== "Chrome") {
   window.parent.close();
}else{
window.close();
}
}
</script>






function   btn_close(){
if (myBrowser()== "Chrome") {
   window.parent.opener.Form1.submit();
   window.parent.close();
}else{
closeModalDialog("<%=refresh%>");
}}


<input  class="BUTTON" type="button" value="关 闭" onclick="closeModalDialog()">



4//"审核不通过"的事件
var auditingAgainst_ret = null;
function auditingAgainst(msgIsReadID){
document.all.audAgainst.disabled=true;
var WindowStyle="dialogHeight:240px; dialogWidth:450px; status=no; center:yes; resizable:yes; help:no";
var url="auditingPupDialog.jsp?msgIsReadID="+msgIsReadID;
var ret=window.showModalDialog(url,window,WindowStyle);   
if (ret == undefined){
   ret = window.returnValue;
 }
if(ret){
if(ret=="false"){
document.all.audAgainst.disabled=false;
return;
}
    auditingAgainst_submit(msgIsReadID);
} else {
    var aa = setInterval(function(msgIsReadID) {
      if (!(null == auditingAgainst_ret || undefined == auditingAgainst_ret)) {
        //document.write(auditingAgainst_ret);
        auditingAgainst_submit(msgIsReadID);
        clearInterval(aa);
      }
    }, 100, msgIsReadID); 
  }
}


function auditingAgainst_submit(msgIsReadID){
document.all.operator.value="auditingAgainst";
    if ("Chrome" == myBrowser()) {
      document.all.reason.value=auditingAgainst_ret;
    } else {
      document.all.reason.value=ret;
    }
document.Form1.action = "bzdxxEditSave.jsp?msgIsReadID="+msgIsReadID;
document.Form1.target = "_self";
document.Form1.submit();
}


<td><a style="cursor:hand" onclick="reOrder('ZDBH')">字典编号</a></td>
<td><a style="cursor:hand" onclick="reOrder('ZDBH')">字典编号</a></td>




//去除字符串的前后空格
function lrtrim(str){
if(str!=undefined||str!=null){
  while((str.length>0) && (str.charAt(0)==' '))
    str = str.substring(1,str.length);
 
  while((str.length>0) && (str.charAt(str.length-1)==' '))
    str = str.substring(0,str.length-1);
}else{str="";}
  return str;



导出
SetUniCode



给wid添加 ‘’

String widStr = "";
ArrayList wid_arr=new ArrayList();
com.ekingstar.zcgl.bean.StringSplit ss = new com.ekingstar.zcgl.bean.StringSplit();
String stkt[] = ss.splitStr(kpbdwidstr,",");
if(!(stkt == null)){
for (int k = 0;k < stkt.length; k++){
wid_arr.add(k,stkt[k].toString());
}
}


for(int n =0 ;n<wid_arr.size();n++){
widStr+="'"+wid_arr.get(n).toString()+"',";
}


if(widStr.length()>0){
widStr = widStr.substring(0,widStr.length()-1);
}


function sucClose(){
alert("代办人设置成功!");
if (myBrowser() == "Chrome"){
if(window.opener != undefined) {
window.opener.parent.left.NQuery();
   window.close();
}
}else{
closeModalDialog("2");
}
}








如果谷歌无法关闭 可能是编辑页面


跳转的时候没有这样写




document.Form1.action = "bzdxxEditSave.jsp?fromzclx="+fromzclx+"&sfsyctj="+sfsyctj+"&sub_mit="+sub_mit;
document.Form1.target = "_self";
document.Form1.submit();


编辑页面的保存(这样的写法是错误的)
var url="dbrsz_Save.jsp?dbrbh="+document.all.hidProxy.value+"&yhbh="+document.all.yhbh.value+"&ywbh="+document.all("ywbh").value+"&t=" + timstamp;;
var ret=window.showModalDialog(url,setRead,WindowStyle);
if (ret == undefined){
ret = window.returnValue;
}
if(ret){
if(ret==2){
window.returnValue=2;
window.close();
}
}
}


IE提交的方式   document.form1.submit();
谷歌提交的方式     window.opener.document.form1.submit();


if (window.opener != undefined){
window.parent.opener.form1.action="ndjh_addPage.jsp?widstr="+selewid;
window.parent.opener.form1.submit();
}else{
window.returnValue = selewid;
}
注意;parent在前在后好像无所谓


注意: window.parent.parent.parent.opener默认为最近一个父窗体

out.print("<script> if(window.opener != undefined) { window.opener.Form1.submit();window.close();}else{closeModalDialog('2');}</script>");

一个方法也要加window.parent.opener.getBmbh();


刷新父窗口

window.opener.location.reload();



0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 机票的保险发票怎么办 行李办理托运后怎么办 飞机托运超尺寸怎么办 机票无托运行李怎么办 飞机票不含托运怎么办 登机重量超了怎么办 随身行李超重了怎么办 国际航班没带护照怎么办 派出所不开户籍怎么办 做火车没身份证怎么办 2018年怎么办户籍证明 一岁宝宝护照怎么办 户籍证明开不了怎么办 信用卡提不了额怎么办 信用卡提额诈骗怎么办 信用卡提额失败怎么办 身份证证件号错误怎么办 东西落在飞机上怎么办 乘高铁忘记带身份证怎么办 身份证丢坐火车怎么办 苏州市民a卡怎么办 集体户口户口页怎么办 网上不能买火车票怎么办 集体户口离婚时怎么办 没户口本怎么办结婚证 酒店没带身份证怎么办 住酒店拍身份证怎么办 手机取火车票要怎么办 香港酒店没登记怎么办 住宿未带身份证怎么办 长期住酒店怎么办暂住证 港澳通行过期了怎么办 异地社保卡怎么办出来 住酒店换洗衣服怎么办 住酒店车被划了怎么办 住酒店身份证丢失怎么办 没有社保卡医院怎么办 宾馆未带身份证怎么办 医保住院未登记怎么办 住酒店房卡丢了怎么办 社保卡读取不了怎么办