网页小亮点之---点击页面中部召唤出导航菜单
来源:互联网 发布:.tv是什么域名 编辑:程序博客网 时间:2024/04/28 00:49
-----------------------------------支持IE firefox等主流浏览器-----------------------------------------------------------
js代码(基于jquery)
/********************获取当前浏览器中页面的宽和高**********************************/function getHeight(){ var yScroll; if (window.innerHeight && window.scrollMaxY) { yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari yScroll = document.body.offsetHeight; } var windowHeight; if (self.innerHeight) { // all except Explorer windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = windowHeight; //始终取屏幕高度(如要取页面高度 可设置 pageHeight = yScroll) } return pageHeight; } function getWidth(){ var xScroll if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; } else { xScroll = document.body.offsetWidth; } var windowWidth if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; } if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } return pageWidth; } /*******************调出页面导航****************/ function show_tools(e){ if(event.button == 2)//按了鼠标右键(防止鼠标左击事件被占用) { var x; var y; x = event.clientX;//获得客户端X坐标 y = event.clientY;//获得客户端Y坐标 //alert(x+"*******"+y); 以下是定位触发区域的坐标 可设置多组 leftx = getWidth()*0.45; //x轴坐标 leftmax = getWidth()*0.45+100; topy = getHeight()*0.45;//y轴坐标 topmax = getHeight()*0.4+100; leftx2 = getWidth()*0.3; leftmax2 = getWidth()*0.3+200; topy2 = getHeight()*0; topmax2 = getHeight()*0+100; // alert(x+"****"+leftx+"%%%%%%%"+y+"*******"+topy); //alert (x>leftx && x<leftmax && y>topy && y<topmax); if(x>leftx && x<leftmax && y>topy && y<topmax) { //alert("dsda"); $('.tcc').toggle("slow");//在此坐标内点击触发的事件 } if(x>leftx2 && x<leftmax2 && y>topy2 && y<topmax2) { $('.hs').toggle("slow"); } }}//以下是鼠标事件绑定 针对浏览器兼容做了处理$(function(){ if($.browser.msie){document.onmousedown=show_tools;//鼠标右键指向show_toolsdocument.oncontextmenu = function(){return false;}//禁止右键}else{document.oncontextmenu = function(e){ var x; var y; x = e.clientX;//获得客户端X坐标 y = e.clientY;//获得客户端Y坐标// alert(x+"*******"+y); leftx = getWidth()*0.4; leftmax = getWidth()*0.4+150; topy = getHeight()*0.35; topmax = getHeight()*0.35+150; leftx2 = getWidth()*0.3; leftmax2 = getWidth()*0.3+200; topy2 = getHeight()*0; topmax2 = getHeight()*0+100; if(x>leftx && x<leftmax && y>topy && y<topmax) { $('.tcc').toggle("slow"); } if(x>leftx2 && x<leftmax2 && y>topy2 && y<topmax2) { $('.hs').toggle("slow"); }return false;}//禁止右键}})
母亲节要到了 祝妈妈节日快乐 大家要是觉得本文还有点帮助 不妨帮忙点击下我的站吧 节日淘礼 go去看看
html代码:
tcc的div即 召唤出的div 里面内容自定义
<div class="tcc"> <div class="topleft"></div> <div class="topright"></div> <div class="botleft"></div> <div class="botright"></div></div>
母亲节要到了 祝妈妈节日快乐 大家要是觉得本文还有点帮助 不妨帮忙点击下我的站吧 节日淘礼 go去看看
css代码:(主要属性使用红色标记)
/********************窗口中心弹窗********************************/.tcc{background-image: url(../images/jieritao3.gif);width:150px;height:150px;background-position: 0 0;display:none;position:fixed;top:45%;left:45%;border:#0F0 inset 2px;z-index:300;} .topleft{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:0 0px;float:left;margin:0 0;}.topleft:hover{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:0 149px;float:left;margin:0 0;}.topright{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:50px 0px;float:right;margin:0 0;} .topright:hover{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:50px 145px;float:right;margin:0 0;}.botleft{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:0px 208px;float:left;margin-top:43px;}.botleft:hover{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:0px 57px;float:left;margin-top:43px;}.botright{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:50px 208px;float:left;margin-top:43px;margin-left:48px;}.botright:hover{width:51px;height:51px;background-image: url(../images/jieritao3.gif);background-position:50px 57px;float:left;margin-top:43px;margin-left:48px;}
- 网页小亮点之---点击页面中部召唤出导航菜单
- 页面左边滑出导航菜单
- 底部菜单导航点击切换页面事件(无ViewPager)
- 滑出式网页导航菜单
- 滑出式网页导航菜单
- 网页特效 ? 菜单导航
- 网页导航菜单制作
- 网页中弹出小窗口(页面背景直接半透明)
- 网页中弹出小窗口,页面背景逐渐变为半透明
- 网页中弹出小窗口,页面背景逐渐变为半透明
- 网页中弹出小窗口,页面背景逐渐变为半透明
- 网页中弹出小窗口,页面背景逐渐变为半透明
- 点击放大导航栏菜单
- 点击弹出导航导航按钮菜单
- ECSHOP 小程序底部滑出效果,淡入效果,底部菜单导航,加入购物车
- 使用ADF Controller 之二:菜单与页面导航
- 可放在网页旁边的导航菜单,点击向右边展开
- 纵向导航菜单,点击产生二级菜单
- 装饰模式
- sqlit
- easyui与框架整合需要注意的问题
- 状态模式
- CF:78A. Haiku
- 网页小亮点之---点击页面中部召唤出导航菜单
- objective-c NSDictionary(字典)
- Spring--quartz中cronExpression配置说明
- 内外物理隔离的特点
- ASM磁盘的添加与删除
- 如何内置iperf到手机中
- 消息队列
- C语言中文件的简单写入_2
- 如何adb shell进入ctia模式