浏览器打开层自动缓慢展开收缩实例代码 - Web前端
作者:98wpeu发布时间:2026-07-10分类:网页前端技术浏览:3
导读:例子:复制代码代码如下:<!DOCtypehtmlPUBLIC"-//W3C//DTDxhtml1.0Strict//EN""http://www.w3.org...
例子:
复制代码 代码如下:
<!DOCtypehtml PUBLIC "-//W3C//DTD xhtml 1.0 Strict//EN" "http://www.w3.org/TR/xHTML1/DTD/xhtml1-strict.dtd">
<html xmlns="HTTP://www.w3.org/1999/xhtml">
<head>
<meta http-eqUIv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#screefull{display:block; border:1px solid #bddbf3; width:954px; padding:3px 5px 7px; margin:0 auto 10px; background:#fef9db; }
#mostrar{display:block; width:954px; display:none;}
#screefull a.close{ display:block; width:25px; height:20px; background:url(img/cx.gif) no-repeat 0 0; overflow:hidden; float:right; margin:16px 8px 0 0; *margin-right:5px; text-decoration:none;}
#screefull p{ display:block; text-align:center; font-family:"microsoft Yahei"; font-size:14px; color:#000; height:28px; line-height:28px; vertical-align:middle;}
#screefull var{ display:inline-block; *display:inline; *Zoom:1; background:url(img/wicon.gif) no-repeat 0 0; width:28px; height:28px; overflow:hidden; vertical-align:middle; margin-right:10px;}
#screefull em{ display:inline-block; *display:inline; *zoom:1; color:#ff0000; font-family:"Microsoft Yahei"; font-style:normal;}
#screefull span{ display:inline-block; *display:inline; *zoom:1; vertical-align:middle;}
#screefull p a{ display:inline-block; *display:inline; *zoom:1; color:#2400ff; text-decoration:underline;}
</style>
<script type="text/javascript" src="JS/JQuery.js"></script>
</head>
<body>
<!--begin:1-->
<div id="warn" class="scree clearfix" style="display:none;">
<div id="screefull">
<a href="#" class="close" onclick="closewarn('close')">[x]</a>
<p><span>在<em>未通过审核的网站</em>添加广告代码,将不会产生佣金。<a href="#" target="_blank" >我知道了</a></span></p>
</div>
</div>
<script type="text/JavaScript">
function closewarn(type)
{
$("#warn").slideUp("slow");
if(type == 'know')
{
$.post(window.location.href,{op : 'setwarn'},function(data)
{
return true;
});
}
}
window.onload = function()
{
$("#warn").slideDown(2000);
}
</script>
<!--end:1-->
</body>
</html>
解释上面代码段:
1、$("#warn").slideUp("slow");向上滑动, $("#warn").slideDown(2000);向下滑动
2、$.post(window.location.href,{op : 'setwarn'},function(data)
{
return true;
})
运用到了Ajax 提交 跟服务器进行交互,
第一个参数是请求的地址 第二个是提交的参数 第三个是请求成功 之后调用的方法
参数op 的值是setwarn json串的格式具体运用解说看http://www.w3school.com.cn/jQuery/ajax_post.asp
url 对应 locaotion.href(取得是当前页面的地址)
data对应 {op:setwarn} 字符串
success 对应 函数
3、window.onload = function(){}作用一般在<text/Javascript>中写的函数都要在body页面中调用,用此函数就不用等着body页面中调用就可以执行了
复制代码 代码如下:
<!DOCtypehtml PUBLIC "-//W3C//DTD xhtml 1.0 Strict//EN" "http://www.w3.org/TR/xHTML1/DTD/xhtml1-strict.dtd">
<html xmlns="HTTP://www.w3.org/1999/xhtml">
<head>
<meta http-eqUIv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#screefull{display:block; border:1px solid #bddbf3; width:954px; padding:3px 5px 7px; margin:0 auto 10px; background:#fef9db; }
#mostrar{display:block; width:954px; display:none;}
#screefull a.close{ display:block; width:25px; height:20px; background:url(img/cx.gif) no-repeat 0 0; overflow:hidden; float:right; margin:16px 8px 0 0; *margin-right:5px; text-decoration:none;}
#screefull p{ display:block; text-align:center; font-family:"microsoft Yahei"; font-size:14px; color:#000; height:28px; line-height:28px; vertical-align:middle;}
#screefull var{ display:inline-block; *display:inline; *Zoom:1; background:url(img/wicon.gif) no-repeat 0 0; width:28px; height:28px; overflow:hidden; vertical-align:middle; margin-right:10px;}
#screefull em{ display:inline-block; *display:inline; *zoom:1; color:#ff0000; font-family:"Microsoft Yahei"; font-style:normal;}
#screefull span{ display:inline-block; *display:inline; *zoom:1; vertical-align:middle;}
#screefull p a{ display:inline-block; *display:inline; *zoom:1; color:#2400ff; text-decoration:underline;}
</style>
<script type="text/javascript" src="JS/JQuery.js"></script>
</head>
<body>
<!--begin:1-->
<div id="warn" class="scree clearfix" style="display:none;">
<div id="screefull">
<a href="#" class="close" onclick="closewarn('close')">[x]</a>
<p><span>在<em>未通过审核的网站</em>添加广告代码,将不会产生佣金。<a href="#" target="_blank" >我知道了</a></span></p>
</div>
</div>
<script type="text/JavaScript">
function closewarn(type)
{
$("#warn").slideUp("slow");
if(type == 'know')
{
$.post(window.location.href,{op : 'setwarn'},function(data)
{
return true;
});
}
}
window.onload = function()
{
$("#warn").slideDown(2000);
}
</script>
<!--end:1-->
</body>
</html>
解释上面代码段:
1、$("#warn").slideUp("slow");向上滑动, $("#warn").slideDown(2000);向下滑动
2、$.post(window.location.href,{op : 'setwarn'},function(data)
{
return true;
})
运用到了Ajax 提交 跟服务器进行交互,
第一个参数是请求的地址 第二个是提交的参数 第三个是请求成功 之后调用的方法
参数op 的值是setwarn json串的格式具体运用解说看http://www.w3school.com.cn/jQuery/ajax_post.asp
url 对应 locaotion.href(取得是当前页面的地址)
data对应 {op:setwarn} 字符串
success 对应 函数
3、window.onload = function(){}作用一般在<text/Javascript>中写的函数都要在body页面中调用,用此函数就不用等着body页面中调用就可以执行了
相关推荐
- jQuery中获取Radio元素值的方法 - Web前端
- jquery异步跨域访问代码 - Web前端
- 浅析JQuery获取和设置Select选项的常用方法总结 - Web前端
- Jquery显示和隐藏元素或设为只读(含Ligerui的控件禁用,实例说明介绍) - Web前端
- jquery的ajaxSubmit()异步上传图片并保存表单数据演示代码 - Web前端
- jquery点击页面任何区域实现鼠标焦点十字效果 - Web前端
- jQuery基本选择器选择元素使用介绍 - Web前端
- 关于JQuery($.load)事件的用法和分析 - Web前端
- jquery中文乱码的多种解决方法 - Web前端
- jquery移除button的inline onclick事件(已测试及兼容浏览器) - Web前端
- 网页前端技术排行
-
- 1分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 2jQuery编写widget的一些技巧分享 - Web前端
- 3【第六章】Foundation之按钮和下拉功能 - Web前端
- 4基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 5在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 6分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 7jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 8[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 9javascript原生和jquery库实现iframe自适应高度和宽度 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性


