关于页面兼容IE8所遇到的问题及解决

本文主要探讨了在IE8及以下版本浏览器中遇到的页面兼容性问题,包括input标签的提示消息显示和CSS颜色渐变。针对input标签的placeholder属性不支持,提出了使用JavaScript实现的解决方案;对于CSS线性渐变,介绍了使用filter和-ms-filter解决IE8的兼容性问题,并提供相关参考资料链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、input标签中提示消息在IE9及以下不兼容问题;

支持HTML5的浏览器可以使用:

<input type="text" id="why" placeholder="请填写维护原因">

IE不支持的情况下可以如下使用:

<input id="why" type="text" value="请填写维护原因" οnfοcus="if (value =='请填写维护原因'){value =''}"οnblur="if (value ==''){value='请填写维护原因'}"/>

另外在密码框中显示提示信息,因为IE8不支持placeholder属性,上述input也无法满足,可以如下使用:

<input type="text" class="form-control"  value="口令" id="text"/>
<input type="password" class="form-control" name="password" id="password" /> 


 <style type="text/css">
 #pwd{
display:none;
}
</style>
<script type="text/javascript"> 
window.οnlοad=function(){
var tx=document.getElementById("text");
var pwd=document.getElementById("password"); 
tx.οnfοcus=function(){ 
if(this.value!="口令") 
return; 
this.style.display="none"; 
pwd.style.display="block"; 
pwd.value=""; 
pwd.focus(); 

pwd.οnblur=function(){ 
if(this.value!=""){
return; 

this.style.display="none"; 
tx.style.display=""; 
tx.value="口令"; 

}
</script> 


2、关于css中颜色的渐变问题;

一般线性渐变 -- linear-gradient

background:linear-gradient(#75B8D9,#fff);

在IE8中是不支持linear-gradient的,使用如下:

filter:alpha(opacity=100 finishopacity=50 style=1 startx=0,starty=0,finishx=0,finishy=150) progid:DXImageTransform.Microsoft.gradient(startcolorstr=#75B8D9,endcolorstr=#ffffff,gradientType=0);


    -ms-filter:alpha(opacity=100 finishopacity=50 style=1 startx=0,starty=0,finishx=0,finishy=150) progid:DXImageTransform.Microsoft.gradient(startcolorstr=#75B8D9,endcolorstr=#ffffff,gradientType=0);


关于颜色渐变的问题下面网址可以有用

http://www.jb51.net/css/511433.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值