Home Web Front-end JS Tutorial Collection of classic JavaScript effects_javascript skills

Collection of classic JavaScript effects_javascript skills

May 16, 2016 pm 06:23 PM

一 实用且必用的小脚本代码
二 鼠标旁边的提示信息,类似与163登录后的页面提示效果
三 如果文字过长,则将过长的部分变成省略号显示
四 滚动的图片
五 接收键盘指令的脚本
六 让你的文本链接渐隐渐显
七 类似与QQ的好友/黑名单之类的树型菜单-----推荐
八 很多的脚本翻页------推荐
九 DIV的透明层实现
十 JSP页面自动生成html页面/或任何格式页面-----推荐

十一 超级强大的表单验证-----推荐
十二 漂亮的脚本日历
十三 进入,退出页面的各种效果!
十四 很酷的效果,表格被选中回变颜色
十五 弹出提示的效果
十六 图片之间的切换
十七 DIV_圆边圆角的实现
十八 跳动的菜单
十九 通过页面抓取照片
二十 客户端静态页面玩分页

二十一 类似与google个性页面的好东东------网友155120
二十二 漂亮的表格
二十三 经典的带阴影的可拖动的浮动层------网友marvellous--------推荐
二十四 运行代码的代码------网友:Lenvo
二十五 凹陷文字------------网友:Lenvo
二十六 漂亮的仿flash菜单---网友:Lenvo
二十七 自定义容器和字体大小---网友:greengnn
二十八 超级REAL视频播放器---网友:leaf52
二十九 网站论坛上面快捷键提交表单的方法---网友:greengnn
三 十 accesskey 提交---网友:greengnn
三十一 新闻广告图片切换效果+描述---网友:greengnn
三十二 菜单特效---网友:greengnn
三十三 采用CSS和JS的下拉菜单---网友:greengnn

 

一 实用且必用的小脚本代码:

脚本1:进入主页以后自动播放声音

脚本2:进入主页后自动最大话,省的去在自己单击了

<script> <br>self.moveTo(0,0) <br>self.resizeTo(screen.availWidth,screen.availHeight) <br></script>

脚本3:显示现在时间的脚本

脚本4:显示最后修改时间的脚本

<script>document.write(document.lastModified)</script>

脚本5:设为首页,加为收藏,加入频道,启动outlook发信

 onclick="this.style.behavior="url(#default#homepage)";
this.setHomePage(http://10.13.31.90/~kayvin/);">">设为首页

onclick="window.external.AddFavorite(location.href,document.title);">加入收藏

加入频道

与我联系

 

脚本6:状态栏动态显示现在时间

<script> <br>function see(){ <br>window.setTimeout("see()",1000); <br>today = new Date(); <br>self.status = today.toString(); <br>} <br></script>

脚本7:关闭窗口的脚本

[关闭窗口]

脚本8:按下F12键,直接返回首页

<script>function look(){ <br>if(event.keyCode==123){document.location.href=http://10.13.31.90/~kayvin/} <br>} <br>if(document.onkeydown==null) <br>{document.onkeydown=look} <br></script>

脚本9:后退,刷新,前进

 

脚本10:设定时间弹出窗口,4000=4秒,当然你可以自定义

<script>function l() <br>{ <br>window.open(" 10.13.31.90/~kayvin/ ","name","width=500,height=150,border=0") <br>} <br>setTimeout("l()",4000) </p> <p></script>

 

二 鼠标旁边的提示信息,类似与163登录后的页面提示效果:

代码拷贝框

 

三 如果文字过长,则将过长的部分变成省略号显示:

运行代码框

四 滚动的图片

运行代码框

五 接收键盘指令的脚本:

代码拷贝框

六 让你的文本链接渐隐渐显:

运行代码框

七 类似与QQ的好友/黑名单之类的树型菜单_极品:

运行代码框

八 很多的脚本翻页:

Run code box

九 DIV的透明层实现:

运行代码框

 

十 JSP页面自动生成html页面/或任何格式页面:

先建立一个模本页面:template.htm

代码拷贝框

再写一个JSP页面: buildhtml.jsp:

 

代码拷贝框

[Ctrl+A 全部选择 然后拷贝]

十一 超级强大的表单验证:

Run code box
Autobiography: <script> /************************************************* Validator v1.01 code by I am from Foshan wfsr@cunite.com http://www.cunite.com *************************************************/ Validator = { Require: /. /, Email: /^w ([- .]w )*@w ([-.]w )*.w ([-.]w )*$/, Phone: /^(((d{3}))|(d{3}-))?((0d{2,3})|0d{2,3}-)?[1-9]d{6 ,7}$/, Mobile: /^(((d{3}))|(d{3}-))?13d{9}$/, Url: /^http://[A-Za-z0-9] .[A-Za-z0-9] [/=?%-&_~`@[]': !]*([^<&gt ;""])*$/, IdCard: /^d{15}(d{2}[A-Za-z0-9])?$/, Currency: /^d (.d )?$/, Number : /^d $/, Zip: /^[1-9]d{5}$/, QQ: /^[1-9]d{4,8}$/, Integer : /^[- ]?d $/, Double : /^[- ]?d (.d )?$/, English : /^[A-Za-z] $/, Chinese : /^[u0391-uFFE5] $/, UnSafe : /^(([A-Z]*|[a-z]*|d*|[-_~!@#$%^&*.()[]{}<>?\/'"]*) |.{0,5})$|s/, IsSafe: function(str){return !this.UnSafe.test(str);}, SafeString : "this.IsSafe(value)", Limit : "this.limit(value.length,getAttribute('min'), getAttribute('max'))", LimitB : "this.limit(this.LenB(value), getAttribute('min'), getAttribute('max'))", Date : "this.IsDate(value, getAttribute('min'), getAttribute('format'))", Repeat : "value == document.getElementsByName(getAttribute('to'))[0].value", Range : "getAttribute('min') < value && value < getAttribute('max')", Compare : "this.compare(value,getAttribute('operator'),getAttribute('to'))", Custom : "this.Exec(value, getAttribute('regexp'))", Group : "this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))", ErrorItem : [document.forms[0]], ErrorMessage : ["以下原因导致提交失败: \t\t\t"], Validate : function(theForm, mode){ var obj = theForm || event.srcElement; var count = obj.elements.length; this.ErrorMessage.length = 1; this.ErrorItem.length = 1; this.ErrorItem[0] = obj; for(var i=0;i<count;i++){ with(obj.elements[i]){ var _dataType = getAttribute("dataType"); if(typeof(_dataType) == "object" || typeof(this[_dataType]) == "undefined") continue; this.ClearState(obj.elements[i]); if(getAttribute("require") == "false" && value == "") continue; switch(_dataType){ case "Date" : case "Repeat" : case "Range" : case "Compare" : case "Custom" : case "Group" : case "Limit" : case "LimitB" : case "SafeString" : if(!eval(this[_dataType])) { this.AddError(i, getAttribute("msg")); } break; default : if(!this[_dataType].test(value)){ this.AddError(i, getAttribute("msg")); } break; } } } if(this.ErrorMessage.length > 1){ mode = mode || 1; var errCount = this.ErrorItem.length; switch(mode){ case 2 : for(var i=1;i<errCount;i++) this.ErrorItem[i].style.color = "red"; case 1 : alert(this.ErrorMessage.join("\n")); this.ErrorItem[1].focus(); break; case 3 : for(var i=1;i<errCount;i++){ try{ var span = document.createElement("SPAN"); span.id = "__ErrorMessagePanel"; span.style.color = "red"; this.ErrorItem[i].parentNode.appendChild(span); span.innerHTML = this.ErrorMessage[i].replace(/\d+:/,"*"); } catch(e){alert(e.description);} } this.ErrorItem[1].focus(); break; default : alert(this.ErrorMessage.join("\n")); break; } return false; } return true; }, limit : function(len,min, max){ min = min || 0; max = max || Number.MAX_VALUE; return min <= len && len <= max; }, LenB : function(str){ return str.replace(/[^\x00-\xff]/g,"**").length; }, ClearState : function(elem){ with(elem){ if(style.color == "red") style.color = ""; var lastNode = parentNode.childNodes[parentNode.childNodes.length-1]; if(lastNode.id == "__ErrorMessagePanel") parentNode.removeChild(lastNode); } }, AddError : function(index, str){ this.ErrorItem[this.ErrorItem.length] = this.ErrorItem[0].elements[index]; this.ErrorMessage[this.ErrorMessage.length] = this.ErrorMessage.length + ":" + str; }, Exec : function(op, reg){ return new RegExp(reg,"g").test(op); }, compare : function(op1,operator,op2){ switch (operator) { case "NotEqual": return (op1 != op2); case "GreaterThan": return (op1 > op2); case "GreaterThanEqual": return (op1 >= op2); case "LessThan": return (op1 < op2); case "LessThanEqual": return (op1 <= op2); default: return (op1 == op2); } }, MustChecked : function(name, min, max){ var groups = document.getElementsByName(name); var hasChecked = 0; min = min || 1; max = max || groups.length; for(var i=groups.length-1;i>=0;i--) if(groups[i].checked) hasChecked++; return min <= hasChecked && hasChecked <= max; }, IsDate : function(op, formatString){ formatString = formatString || "ymd"; var m, year, month, day; switch(formatString){ case "ymd" : m = op.match(new RegExp("^((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})$")); if(m == null ) return false; day = m[6]; month = m[5]--; year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10)); break; case "dmy" : m = op.match(new RegExp("^(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))$")); if(m == null ) return false; day = m[1]; month = m[3]--; year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10)); break; default : break; } if(!parseInt(month)) return false; month = month==12 ?0:month; var date = new Date(year, month, day); return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()); function GetFullYear(y){return ((y<30 ? "20" : "19") + y)|0;} } } </script>

十二 漂亮的脚本日历:

运行代码框

十三 进入,退出页面的各种效果:

进入页面
推出页面
这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:
  0 矩形缩小
  1 矩形扩大
  2 圆形缩小
  3 圆形扩大
  4 下到上刷新
  5 上到下刷新
  6 左到右刷新
  7 右到左刷新
  8 竖百叶窗
  9 横百叶窗
  10 错位横百叶窗
  11 错位竖百叶窗
  12 点扩散
  13 左右到中间刷新
  14 中间到左右刷新
  15 中间到上下
  16 上下到中间
  17 右下到左上
  18 右上到左下
  19 左上到右下
  20 左下到右上
  21 横条
  22 竖条
  23 以上22种随机选择一种

十四 很酷的效果,表格被选中回变颜色:

运行代码框

十五 弹出提示的效果:

运行代码框

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if I encounter garbled code printing for front-end thermal paper receipts? What should I do if I encounter garbled code printing for front-end thermal paper receipts? Apr 04, 2025 pm 02:42 PM

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

Who gets paid more Python or JavaScript? Who gets paid more Python or JavaScript? Apr 04, 2025 am 12:09 AM

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

How to merge array elements with the same ID into one object using JavaScript? How to merge array elements with the same ID into one object using JavaScript? Apr 04, 2025 pm 05:09 PM

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

How to achieve parallax scrolling and element animation effects, like Shiseido's official website?
or:
How can we achieve the animation effect accompanied by page scrolling like Shiseido's official website? How to achieve parallax scrolling and element animation effects, like Shiseido's official website? or: How can we achieve the animation effect accompanied by page scrolling like Shiseido's official website? Apr 04, 2025 pm 05:36 PM

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

The difference in console.log output result: Why are the two calls different? The difference in console.log output result: Why are the two calls different? Apr 04, 2025 pm 05:12 PM

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Is JavaScript hard to learn? Is JavaScript hard to learn? Apr 03, 2025 am 12:20 AM

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

How to implement panel drag and drop adjustment function similar to VSCode in front-end development? How to implement panel drag and drop adjustment function similar to VSCode in front-end development? Apr 04, 2025 pm 02:06 PM

Explore the implementation of panel drag and drop adjustment function similar to VSCode in the front-end. In front-end development, how to implement VSCode similar to VSCode...

See all articles