资讯专栏INFORMATION COLUMN

js 遮罩效果

li21 / 2638人阅读

摘要:

  1. -------------------------------tipswindown.js------------------------------
  2. ///-------------------------------------------------------------------------
  3. //jQuery弹出窗口 By Await [2009-11-22]
  4. //--------------------------------------------------------------------------
  5. /*参数:[可选参数在调用时可写可不写,其他为必写]
  6. ----------------------------------------------------------------------------
  7. title: 窗口标题
  8. content: 内容(可选内容为){ text | id | img | url | iframe }
  9. width: 内容宽度
  10. height: 内容高度
  11. drag: 是否可以拖动(ture为是,false为否)
  12. time: 自动关闭等待的时间,为空是则不自动关闭
  13. showbg: [可选参数]设置是否显示遮罩层(0为不显示,1为显示)
  14. cssName: [可选参数]附加class名称
  15. ------------------------------------------------------------------------*/
  16. //示例:
  17. //------------------------------------------------------------------------
  18. //simpleWindown("例子","text:例子","500","400","true","3000","0","exa")
  19. //------------------------------------------------------------------------
  20. var showWindown = true;
  21. var templateSrc = "http://www.7daysinn.cn"; //设置loading.gif路径
  22. function tipsWindown(title,content,width,height,drag,time,showbg,cssName,backcall) {
  23. $("#windown-box").remove(); //请除内容
  24. var width = width>= 950?this.width=950:this.width=width; //设置最大窗口宽度
  25. var height = height>= 527?this.height=527:this.height=height; //设置最大窗口高度
  26. if(showWindown == true) {
  27. var simpleWindown_html = new String;
  28. simpleWindown_html = "
    ";
  29. simpleWindown_html += "
    ";
  30. simpleWindown_html += "

    关闭
    ";
  31. simpleWindown_html += "
    ";
  32. simpleWindown_html += "";
  33. $("body").append(simpleWindown_html);
  34. show = false;
  35. }
  36. contentType = content.substring(0,content.indexOf(":"));
  37. content = content.substring(content.indexOf(":")+1,content.length);
  38. switch(contentType) {
  39. case "text":
  40. $("#windown-content").html(content);
  41. break;
  42. case "id":
  43. $("#windown-content").html($("#"+content+"").html());
  44. break;
  45. case "img":
  46. $("#windown-content").ajaxStart(function() {
  47. $(this).html("");
  48. });
  49. $.ajax({
  50. error:function(){
  51. $("#windown-content").html("

    加载数据出错...

    ");
  52. },
  53. success:function(html){
  54. $("#windown-content").html("");
  55. }
  56. });
  57. break;
  58. case "url":
  59. var content_array=content.split("?");
  60. $("#windown-content").ajaxStart(function(){
  61. $(this).html("");
  62. });
  63. $.ajax({
  64. type:content_array[0],
  65. url:content_array[1],
  66. data:content_array[2],
  67. error:function(){
  68. $("#windown-content").html("

    加载数据出错...

    ");
  69. },
  70. success:function(html){
  71. $("#windown-content").html(html);
  72. if(backcall)
  73. backcall();
  74. }
  75. });
  76. break;
  77. case "iframe":
  78. $("#windown-content").ajaxStart(function(){
  79. $(this).html("");
  80. });
  81. $.ajax({
  82. error:function(){
  83. $("#windown-content").html("

    加载数据出错...

    ");
  84. },
  85. success:function(html){
  86. $("#windown-content").html("");
  87. }
  88. });
  89. }
  90. $("#windown-title h2").html(title);
  91. if(showbg == "true") {$("#windownbg").show();}else {$("#windownbg").remove();};
  92. $("#windownbg").animate({opacity:"0.5"},"normal");//设置透明度
  93. $("#windown-box").show();
  94. if( height >= 527 ) {
  95. $("#windown-title").css({width:(parseInt(width)+22)+"px"});
  96. $("#windown-content").css({width:(parseInt(width)+17)+"px",height:height+"px"});
  97. }else {
  98. $("#windown-title").css({width:(parseInt(width)+10)+"px"});
  99. $("#windown-content").css({width:width+"px",height:height+"px"});
  100. }
  101. var cw = document.documentElement.clientWidth,ch = document.documentElement.clientHeight,est = document.documentElement.scrollTop;
  102. var _version = $.browser.version;
  103. if ( _version == 6.0 ) {
  104. $("#windown-box").css({left:"50%",top:(parseInt((ch)/2)+est)+"px",marginTop: -((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
  105. }else {
  106. $("#windown-box").css({left:"50%",top:"50%",marginTop:-((parseInt(height)+53)/2)+"px",marginLeft:-((parseInt(width)+32)/2)+"px",zIndex: "999999"});
  107. };
  108. var Drag_ID = document.getElementById("windown-box"),DragHead = document.getElementById("windown-title");
  109. var moveX = 0,moveY = 0,moveTop,moveLeft = 0,moveable = false;
  110. if ( _version == 6.0 ) {
  111. moveTop = est;
  112. }else {
  113. moveTop = 0;
  114. }
  115. var sw = Drag_ID.scrollWidth,sh = Drag_ID.scrollHeight;
  116. DragHead.onmouseover = function(e) {
  117. if(drag == "true"){DragHead.style.cursor = "move";}else{DragHead.style.cursor = "default";}
  118. };
  119. DragHead.onmousedown = function(e) {
  120. if(drag == "true"){moveable = true;}else{moveable = false;}
  121. e = window.event?window.event:e;
  122. var ol = Drag_ID.offsetLeft, ot = Drag_ID.offsetTop-moveTop;
  123. moveX = e.clientX-ol;
  124. moveY = e.clientY-ot;
  125. document.onmousemove = function(e) {
  126. if (moveable) {
  127. e = window.event?window.event:e;
  128. var x = e.clientX - moveX;
  129. var y = e.clientY - moveY;
  130. if ( x > 0 &&( x + sw < cw) && y > 0 && (y + sh < ch) ) {
  131. Drag_ID.style.left = x + "px";
  132. Drag_ID.style.top = parseInt(y+moveTop) + "px";
  133. Drag_ID.style.margin = "auto";
  134. }
  135. }
  136. }
  137. document.onmouseup = function () {moveable = false;};
  138. Drag_ID.onselectstart = function(e){return false;}
  139. }
  140. $("#windown-content").attr("class","windown-"+cssName);
  141. if( time == "" || typeof(time) == "undefined") {
  142. $("#windown-close").click(function() {
  143. showselect("t123_")
  144. $("#windownbg").remove();
  145. $("#windown-box").fadeOut("slow",function(){$(this).remove();});
  146. });
  147. }else {
  148. setTimeout(closeWindown,time);
  149. }
  150. hideselect("t123_");
  151. }
  152. var closeWindown = function() {
  153. showselect("t123_");
  154. $("#windownbg").remove();
  155. $("#windown-box").fadeOut("slow",function(){$(this).remove();});
  156. }
  157. function hideselect(per)
  158. {
  159. var _version = $.browser.version;
  160. if ( _version == 6.0 ) {
  161. $("select",document).each(function(){
  162. if($(this).attr("name"))
  163. {
  164. if($(this).attr("name").substring(0,5)==per)
  165. {
  166. name = $(this).attr("name").substring(5);
  167. $(this).attr("name",name);
  168. $(this).css("display","");
  169. }
  170. if($(this).css("display")!="none")
  171. {
  172. name = per+$(this).attr("name");
  173. $(this).attr("name",name);
  174. }
  175. $(this).css("display","none");
  176. }
  177. });
  178. }
  179. }
  180. function showselect(per)
  181. {
  182. var _version = $.browser.version;
  183. if ( _version == 6.0 ) {
  184. $("select",document).each(function(){
  185. if($(this).attr("name"))
  186. {
  187. if($(this).attr("name").substring(0,5)==per)
  188. {
  189. name = $(this).attr("name").substring(5);
  190. $(this).attr("name",name);
  191. $(this).css("display","");
  192. }
  193. }
  194. });
  195. }
  196. }
  197. ---------------------------style.css----------------------------------
  198. ---------------------------------html------------------------------
  199. ?javascript弹出层插件可自定义js弹出层动画特效
  200. ?jquery弹出层鼠标点击弹出层可浮动在屏幕滚动
  201. ?jquery弹出层特效animate制作类似flash动画效果弹出层
  202. ?jquery 弹出层 点击按钮弹出层兼容IE和firefox浏览器
  203. ?jquery 弹出层插件 鼠标点击文字获取标题弹出层内容信息
  204. ?jquery 弹出层插件 ThickBox 多功能弹出层插件支持图片、ajax、内嵌内容弹等
  205. ?jquery 弹出层插件FancyBox弹出层演示支持图片、文章内容、flash swf弹出层等
  206. ?jquery弹出层鼠标点击弹出层可浮动在屏幕滚动
  207. ?jquery弹出层特效animate制作类似flash动画效果弹出层
  208. ?jquery 弹出层 点击按钮弹出层兼容IE和firefox浏览器
  209. ?jquery 弹出层插件 鼠标点击文字获取标题弹出层内容信息
  210. ?jquery 弹出层插件 ThickBox 多功能弹出层插件支持图片、ajax、内嵌内容弹等
  211. ?jquery 弹出层插件FancyBox弹出层演示支持图片、文章内容、flash swf弹出层等
  212. ?javascript弹出层插件可自定义js弹出层动画特效
  213. ?jquery弹出层鼠标点击弹出层可浮动在屏幕滚动
  214. ?jquery弹出层特效animate制作类似flash动画效果弹出层
  215. ?jquery 弹出层 点击按钮弹出层兼容IE和firefox浏览器
  216. ?jquery 弹出层插件 鼠标点击文字获取标题弹出层内容信息
  217. ?jquery 弹出层插件 ThickBox 多功能弹出层插件支持图片、ajax、内嵌内容弹等
  218. ?jquery 弹出层插件FancyBox弹出层演示支持图片、文章内容、flash swf弹出层等
  219. ?jquery弹出层鼠标点击弹出层可浮动在屏幕滚动
  220. ?jquery弹出层特效animate制作类似flash动画效果弹出层
  221. ?jquery 弹出层 点击按钮弹出层兼容IE和firefox浏览器
  222. ?jquery 弹出层插件 鼠标点击文字获取标题弹出层内容信息
  223. ?jquery 弹出层插件 ThickBox 多功能弹出层插件支持图片、ajax、内嵌内容弹等
  224. ?jquery 弹出层插件FancyBox弹出层演示支持图片、文章内容、flash swf弹出层等

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/111346.html

相关文章

  • 有趣的交互系列 - 文字遮罩入场效果

    摘要:在这个系列里分享一些简单,但是很有意思的交互效果附上地址和地址滚动,添加对应加载的比如巧用实现文字和遮罩层的动画效果文字动画遮罩层动画首先然后把且,这样就实现了遮罩层的进场和退出效果随机获取数组项 在这个系列里分享一些简单,但是很有意思的交互效果~附上demo地址和github地址 showImg(https://makapicture.oss-cn-beijing.aliyuncs....

    邹强 评论0 收藏0
  • 有趣的交互系列 - 文字遮罩入场效果

    摘要:在这个系列里分享一些简单,但是很有意思的交互效果附上地址和地址滚动,添加对应加载的比如巧用实现文字和遮罩层的动画效果文字动画遮罩层动画首先然后把且,这样就实现了遮罩层的进场和退出效果随机获取数组项 在这个系列里分享一些简单,但是很有意思的交互效果~附上demo地址和github地址 showImg(https://makapicture.oss-cn-beijing.aliyuncs....

    tyheist 评论0 收藏0
  • 用原生js写出一个弹框+遮罩层的页面,完成弹框垂直居中页面且点击弹框外任何区域去掉弹框和遮罩层的功能

    摘要:背景官网有个对话框组件如图如果哪天不能用框架了不能用组件了只能用原生写页面现在的我可能要一个页面写一年目标用原生完成这个页面弹框处于垂直居中状态且点击弹框外任意区域关闭弹框写了很久很久时间就不说了遇到的最难的问题就是不知道怎么关闭弹框后面还 背景:Ant官网有个对话框Model组件.如图: showImg(https://segmentfault.com/img/bVbwMCG?w=1...

    betacat 评论0 收藏0
  • 用原生js写出一个弹框+遮罩层的页面,完成弹框垂直居中页面且点击弹框外任何区域去掉弹框和遮罩层的功能

    摘要:背景官网有个对话框组件如图如果哪天不能用框架了不能用组件了只能用原生写页面现在的我可能要一个页面写一年目标用原生完成这个页面弹框处于垂直居中状态且点击弹框外任意区域关闭弹框写了很久很久时间就不说了遇到的最难的问题就是不知道怎么关闭弹框后面还 背景:Ant官网有个对话框Model组件.如图: showImg(https://segmentfault.com/img/bVbwMCG?w=1...

    CoderDock 评论0 收藏0
  • CSS遮罩层:hover状态丢失及解决方案

    摘要:在时,亦可进一步改变该遮罩层的色彩和透明度。遮罩层实现及状态丢失问题代码代码在时,如果快速点击鼠标,可能会丢失的效果。状态丢失的简单解决方案基本思路是,点击鼠标时给添加,强制它显示里的样式。 CSS遮罩层,顾名思义就是在div上,再铺一层半透明的div。在hover时,亦可进一步改变该遮罩层的色彩和透明度。我们可以通过css定位和背景色实现。 CSS遮罩层实现及hover状态丢失问题 ...

    vincent_xyb 评论0 收藏0
  • CSS遮罩层:hover状态丢失及解决方案

    摘要:在时,亦可进一步改变该遮罩层的色彩和透明度。遮罩层实现及状态丢失问题代码代码在时,如果快速点击鼠标,可能会丢失的效果。状态丢失的简单解决方案基本思路是,点击鼠标时给添加,强制它显示里的样式。 CSS遮罩层,顾名思义就是在div上,再铺一层半透明的div。在hover时,亦可进一步改变该遮罩层的色彩和透明度。我们可以通过css定位和背景色实现。 CSS遮罩层实现及hover状态丢失问题 ...

    Steven 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<