自己积累的网页设计常用素材

1.兼容ie8及以下的html5标签的js脚本

<!--[if lt IE 9]>
   <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

2.ie6浏览器提示升级

<script type="text/javascript">
var ie6=!-[1,]&&!window.XMLHttpRequest;
if(ie6){
document.write('<div style="width:600px; margin:50px auto; border:1px #EEE solid; background:#f5f5f5; padding:30px;">');
document.write('<p>亲爱的用户您好,我们检测到你目前使用的浏览器版本仍然是IE6,为了不影响你的正常使用,强烈建议您使用更优秀的浏览器<a href="http://www.google.cn/chrome/intl/zh-CN/landing_chrome.html" target="_blank">Chrome</a> 或者 <a href="http://firefox.com.cn/download/" target="_blank">Firefox</a> 浏览器。感谢您的理解。</p>');
document.write('</div>');
document.write('');
}
</script>

3.简易的AJAX代码

<script type="text/javascript">
	var url="http://localhost/1.php?id=*";
	var ajax=null;
	if(window.XMLHttpRequest){
		ajax=new XMLHttpRequest();
	}else if(window.ActiveXObject){
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		//return;
	}
	ajax.open("GET",url,true);
	ajax.send(null);
	ajax.onreadystatechange=function(){
		if(ajax.readyState==4 && ajax.status==200){
			alert(ajax.responseText);
		}
	}
</script>

4.浏览器3秒钟自动跳转代码

<script type="text/javascript">
	//1.页面无提示,3秒钟后跳转
	window.setTimeout("location.href='*.html'",3000);
</script>

	<script type="text/javascript"> 
	//2.页面文字提示和时间倒计时,以及如果不跳转可以点击链接跳转
	function delayURL(url){
var delay=document.getElementById("time").innerHTML;
if(delay>0){
delay--;
document.getElementById("time").innerHTML=delay;
}else{
window.location.href=url;
}
setTimeout("delayURL('" + url + "')", 1000);
}
</script>
<span id="time" style="background: red">3</span> 秒钟之后自动跳转,如果不跳转,请点击下面链接<a href="*.html"></a>
<script type="text/javascript"> delayURL("*.html"); </script>

5.点击按钮运行页面中的html代码

<!doctype html>
<html>
<head>
<title>运行代码</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script>
//获取一个对象
function getByid(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	} else {
		return null;
	}
}
function runCode(id){  //定义一个运行代码的函数,
	  var code=getByid(id).value;//即要运行的代码。
	  var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
	  newwin.opener = null // 防止代码对脚本页面修改
	  newwin.document.write(code);  //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
	  newwin.document.close();
}
</script>
<textarea id="runcode" rows="9" cols="72" readonly="readonly">
<script>
alert("这是运行代码结果^_^")
</script>
</textarea>
<br />
<input οnclick="runCode('runcode')" type="button" value="运行代码" />
</body>
</html>

6.页脚固定底部(兼容IE6浏览器)

#footer {
    position: fixed;
    left: 0px;
    bottom: 0px;
    height: 30px;
    width: 100%;
    background: #444;
}
/* IE 6 */
* html #footer {
    position: absolute;
    top: expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值