解决ie8 中 focus函数不好使问题

15 篇文章 1 订阅

在做项目时遇到了这么一个问题,弹出层时,自动让文本框获得焦点,就是$('id').focus();

可问题是次函数在ie9上好使,在ie8上不好使。后来改为js形式document.getELementById('id').focus()也不好使。

后来看到论坛讨论可以通过这种方式解决:

           $("#shadeQRCodeDiv").show();
	   $('.qrCodeDiv').show('fast', function() {
		   $("#wfaId").focus();
	   });

但是项目中用到的是colorbox这个弹出层插件。

没办法,只能自己写一个遮罩了:

#shadeQRCodeDiv{ display: none;  position: absolute;  top:0px;  left:px;  width: 100%;  height: 100%;  background-color: black;  z-index:9997;  -moz-opacity: 0.15;  opacity:0.15;  filter: alpha(opacity=15);}
.qrCodeDiv{
	border: 1px solid #808080;
	overflow:hidden;
	zoom: 1;
	background:  #fff;
}
#qrCodeDiv {
	text-align: center;
	z-index:9998;
	overflow:hidden;
	width: 400px;
	height: 150px;
	left:50%;/*FF IE7*/
	top: 50%;/*FF IE7*/
	margin-left:-200px!important;/*FF IE7 该值为本身宽的一半 */
	margin-top:-75px!important;/*FF IE7 该值为本身高的一半*/
	position:absolute;
}

html 放在body标签根下:

        <div id="shadeQRCodeDiv"></div>
	<div id="qrCodeDiv"  style="display: none;" class="qrCodeDiv">
	   <div class="grayBg">
      		<div class="toolbar">
                      <input type="button" οnclick="closeSuccessDiv();" value=" <s:text name='button.cancel'/> " />
                </div>
           </div>
		<div style="margin-top:20px;">
			<b>审批单编号:</b>  <input type="text" maxlength="50" style="width:200px;" id="wfaId" name="wfaId"/>
		</div>
        </div>

js代码:

 


  function qrCode(){
	   $("#shadeQRCodeDiv").show();
	   $('.qrCodeDiv').show('fast', function() {
		   $("#wfaId").focus();
	    });
	   window.parent.layer();
   }
   function closeSuccessDiv(){
	    $("#shadeQRCodeDiv").hide();
	    $('.qrCodeDiv').hide();
	    window.parent.remove_layer();
   }
   $(function(){
		$("#wfaId").keydown(function(event){
	    	 if(event.keyCode == 13){
	    		document.dataGridForm.action = "<%=request.getContextPath()%>/system/actTask/listTasksByBusinessKey.acti                              on?wfaId=" + $('#wfaId').val();
	 	        document.dataGridForm.submit();
	     	}
	  	}); 
	});


 


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值