`
firstboy
  • 浏览: 40480 次
  • 性别: Icon_minigender_1
  • 来自: 徐州
社区版块
存档分类
最新评论
阅读更多
常用网页设计js收集
文本框焦点问题
onBlur:当失去输入焦点后产生该事件
onFocus:当输入获得焦点后,产生该文件
Onchange:当文字值改变时,产生该事件
Onselect:当文字加亮后,产生该文件
<input type="text" value="likeky" onfocus="if(value=='likeky') {value=''}" onblur="if
(value=='') {value='likeky'}">点击时文字消失,失去焦点时文字再出现

网页按钮的特殊颜色
<input type=button name="Submit1" value="likeky" size=10 class=s02

style="background-color:rgb(235,207,22)">

鼠标移入移出时颜色变化
<input type="submit" value="找吧" name="B1" onMouseOut=this.style.color="blue"

onMouseOver=this.style.color="red"  class="button">

平面按钮
<input type=submit value=订阅 style="border:1px solid :#666666; height:17px; width:25pt; font-size:9pt;

BACKGROUND-COLOR: #E8E8FF; color:#666666" name="submit">



按钮颜色变化
<input type=text name="nick"  style="border:1px solid #666666;  font-size:9pt;  height:17px;

BACKGROUND-COLOR: #F4F4FF; color:#ff6600" size="15" maxlength="16">



平面输入框
<input type="text" name="T1" size="20" style="border-style: solid; border-width: 1">



使窗口变成指定的大小
<script>
window.resizeTo(300,283);
</script>

使文字上下滚动
<marquee direction=up scrollamount=1 scrolldelay=100 onmouseover='this.stop()' onmouseout='this.start()'



height=60>

状态栏显示该页状态
<base onmouseover="window.status='网站建设 http://www.admin5.cn/' ;return true">

打印</a>打印网页
<a href='javascript:window.print ()'>

线型输入框
<input type="text" name="key"  size="12" value="关键字" onFocus=this.select() onMouseOver=this.focus()



class="line">

显示文档最后修改日期
<script language=javascript>
function hi(str)
{
document.write(document.lastModified)



alert("hi"+str+"!")
}
</script>

可以在鼠标移到文字上时就触发事件
<html>
<head>
<script language="LiveScript">
<!-- Hiding
     function hello() {
       alert("哈罗!");
     }
</script>
</head>
<body>
<a href="" onMouseOver="hello()">link</a>
</body>
</html>

改变按钮的图片.
<style type="text/css">
<!--
.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}
.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width:

60px; height: 22px}
-->
</style>

本例的按钮代码如下:
<input type="submit" name="Submit2" value="提 交" onmouseover="this.className='style4'"

onmouseout="this.className='style3'" class="style3">

直接写html语言
document.write("");

改变下拉框的颜色
<select name="classid"



onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)"

size="1" style="color:#008080;font-size: 9pt">

转至目标URL
window.location=http://www.admin5.net

文字标签
<label for="AltName4"><input name="AltName" type="RADIO" tabindex="931"  id="AltName4"

>guoqiang99859</label>

layer2为组件的ID,可以控制组件是否可见
document.all.item('Layer2').style.display = "block";
document.all.item('Layer2').style.display = "none";

将页面加入favorite中
<script language=javascript>
<!--
function Addme(){
url = "http://your.site.address" 你自己的主页地址 ;>
title = "Your Site Name"; //你自己的主页名称
window.external.AddFavorite(url,title);
-->
</script>



过10秒自动关闭页面
< script language="JavaScript" >
function closeit() {
setTimeout("self.close()",10000)
}
< /script >

将字符转化为数字
month = parseInt(char)

改变背景颜色
<td width=* class=dp bgColor=#FAFBFC onmouseover="this.bgColor='#FFFFFF';"

onmouseout="this.bgColor='#FAFBFC';">

改变文字输入框的背景颜色
<style>
.input2 {background-image: url('../images/inputbg.gif');   font-size: 12px; background-color:

#D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
</style>
<input name=content type=text size="47" class="input2" maxlength="50">

改变水平线的特征
<hr size="0" noshade color="#C0C0C0">

刷新页面
javascript:this.location.reload()

后退
<INPUT TYPE="button" onclick=window.history.back() value=back>



前进
<INPUT TYPE="button" onclick=window.history.forward() value=forward>



刷新
<INPUT TYPE="button" onclick=document.location.reload() value=reload>

转向指定网页
document.location="http://www.0051.com" 或者document.location.assign(>http://www.666c.com)

在网页上显示实时时间
cript" >>
var clock_id;
window.onload=function()
{
clock_id=setInterval("document.form1.txtclock.value=(new Date);",1000)
}
</SCRIPT>



可以下载文件
document.location.href="目标文件"

<INPUT TYPE="button" onclick="a1.innerHTML='<font color=red>*</font>'">
<div id=a1></div>

新建frame
<a href="javascript:newframe('http://www.163.net/help/a_little/index.html','http://www.163.net/help/a_little/a_13.html')"><img alt=帮助 border=0src="/upimg/allimg/070206/0926040.gif"></a>

弹出窗口
方法一:<body onload="openwen()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwen()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:<a href="#" onclick="openwin()">打开一个窗口</a>
注意:使用的"#"是虚连接。
方法四:用一个按钮调用:<input type="button" onclick="openwin()" value="打开窗口"> 何时装载script

动态改变字体的大小
function doZoom(size)
{
   document.getElementById('zoom').style.fontSize=size+'px'
}

判断是何种浏览器
var name = navigator.appName;
if (name == "Microsoft Internet Explorer")
alert("IE");
else if (name == "Netscape")
alert("NS");

最小化窗口
window.blur()




文档的路径
document.URL

定时执行某段程序
setTimeout("change_color()",600)

设置为收藏
function addFav(){
  if(ie)
    window.external.AddFavorite(location.href,'WWW.OGRISH.COM : GROTESQUE MOVIES AND PICTURES');
  if(ns)
    alert("Thanks for the bookmark!\n\nNetscape users click OK then press CTRL-D");
}

判断cookie是否可用
navigator.cookieEnabled;



显示有模式的有页面的弹出窗口
function setbgcolor_onclick()
{
var color = showModalDialog("/mailpage/compose/colorsel.html",0,"help=0");
if (color != null)
{
  document.compose.bgcolor.value = color;
}
}


截取小数点后两位
var a=3454545.4454545;
alert(a.toFixed(2)

屏蔽右键菜单
oncontextmenu="event.returnValue = false"

禁止在输入框打开输入法
<input style="ime-mode: disabled">



屏蔽汉字和空格
<input name="txt"><input type="submit" onClick="alert(!/[^ -}]|\s/.test(txt.value))">

用javascript判断文件是否存在
function Exists(filespec)
{
if (filespec)
{
  var fso;
  fso = new ActiveXObject("Scripting.FileSystemObject");
  alert(fso.FileExists(filespec));
}
}
选择图片 <input type=file name=f1><p>
<input type="submit" onClick="Exists(f1.value)">

跳转至目标页面,同时不可返回
<a href="javascript:location.replace('http://www.sohu.com/')">sohu.com</a>//


获得当前的行是表格的第几行
<script>
function getrow(obj)
{
   if(event.srcElement.tagName=="TD"){
   curRow=event.srcElement.parentElement;
   alert("这是第"+(curRow.rowIndex+1)+"行");

   }
}
</script>

<table border="1" width="100%" onclick=getrow(this)>
  <tr>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
  </tr>
  <tr>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
  </tr>
</table>

删除表格某行,xx表示某行,下标从0开始计算
document.all.myTable.deleteRow(xx)

动态的向表格中添加行
<table id="t1" border="1">
</table>
<script language="JavaScript">
function add()
{
   t1.insertRow().insertCell().innerHTML = '<input name="test'+t1.rows.length+'">';
}

打开C盘
<form action="file:///c|>%20type="submit"%20value="c:/%20drive">//

当前屏幕的分辨率
screen.width、screen.height

设置表格中的内容
tbl.rows[0].cells[1].innerText=document.form.text1.value;//


本地快捷键


file:///::{208D2C60-3AEA-1069-A2D7-08002B30309D}"%20target="_blank">网上邻居



file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/d:/web"%20target="_blank">我的电脑



file:///::{450D8FBA-AD25-11D0-98A8-0800361B1103}"%20target="_blank">我的文档



file:///::{645FF040-5081-101B-9F08-00AA002F954E}"%20target="_blank">回收站



file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/::{21EC2020-3AEA-1069-A2DD-08002B30309D}"

target="_blank">控制面板



file:///::{7007ACC7-3202-11D1-AAD2-00805FC1270E}">拨号网络(Windows%202000)

web对话框

var%20contents=' style>?;>
contents+='<title>你要关闭我吗</title>';
contents+='<body bgcolor=menu>';
contents+='<table width=100% height=100% border=0>';
contents+='<tr><td align=center>';
contents+='你要关闭我吗?<br>';
contents+='<img src=dark.gif onclick=self.close() alt="...关闭">';
contents+='<img src=jet.gif onclick=self.close() alt="全是关闭">';
contents+='</td></tr></table>';
showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no")
document.write(contents);
</SCRIPT>

向新打开的网页上写内容
newwin=window.open('about:blank','','top=10');
newwin.document.write('');

返回
javascript:history.go(-2);

改变状态栏
self.status ="";

改变窗口大小
window.resizeTo(200,300);

背景透明
<input type="button" value="Button" style="background-color: transparent; border: 0;">

鼠标为等待形状
<input type=button onclick="this.style.cursor='wait'">

调用父窗口的函数
opener.fucntion1();

body的内部html代码
<input type="button" onclick="alert(code.document.body.innerHTML)" value="查看">

框架中调用父窗口的函数
<INPUT TYPE='button' onclick='parent.test();' value='调用parent窗口的函数'>

交换节点
<table  width=200  height=200  border>
<tr><td  id=c1>CELL_1</td></tr>
<tr><td  id=c2>CELL_2</td></tr>
</table>
<br>
<input  type="button"  value="swap  row"  onclick="c1.swapNode(c2)">

删除节点
<table  width=200  height=200  border>
<tr id=trall><td  id=c1>CELL_1</td></tr>
<tr><td  id=c2>CELL_2</td></tr>
</table>
<br>
<input  type="button"  value="swap  row"  onclick="trall.removeNode(c2)">

添加节点
addNode()

返回输入框的类型
<script>
alert(event.srcElement.type);
</script>

格式化数字
function format_number(str,digit)
{
if(isNaN(str))
{
  alert("您传入的值不是数字!");
  return 0;
}
else if(Math.round(digit)!=digit)
{
  alert("您输入的小数位数不是整数!");
  return 0;
}
else
  return Math.round(parseFloat(str)*Math.pow(10,digit))/Math.pow(10,digit);
}

判断一个数字是否是整数
var a=23.2;
alert(a%1==1)

标题栏
document.title

匹配Email地址的正则表达式:\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*



匹配网址URL的正则表达式:http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?

利用正则表达式去除字串中重复的字符的算法程序:

var s="abacabefgeeii"
var s1=s.replace(/(.).*\1/g,"$1")
var re=new RegExp("["+s1+"]","g")
var s2=s.replace(re,"")
alert(s1+s2)  //结果为:abcefgi

用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^\d]/g,'')

"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"

用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[\W]/g,'')

"onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"

另存为[格式]:document.execCommand("saveAs")
[说明]将该网页保存到本地盘的其它目录!
[举例]在<body></body>之间加入:
<a href="###" onclick=document.execCommand("saveAs")>另存为</a>

关闭命令的实现
[格式]:window.close();return false
[说明]将关闭本窗口。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.close();return false)>关闭本窗口</a>

全屏显示命令的实现
[格式]:window.open(document.location, "url", "fullscreen")
[说明]全屏显示本页。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.open(document.location,"url","fullscreen")>全屏显示</a>

整理收藏夹命令的实现
[格式]:window.external.showBrowserUI("OrganizeFavorites",null)
[说明]打开整理收藏夹对话框。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a>

刷新命令的实现
[格式]:document.reload() 或 history.go(0)
[说明]浏览器重新打开本页。
[举例]在<body></body>之间加入:
<a href="###" onclick=location.reload()>刷新</a>
或加入:
<a href="###" onclick=history.go(0)>刷新</a>


定时关闭本窗口命令的实现
[格式]:settimeout(window.close(),关闭的时间)
[说明]将关闭本窗口。
[举例]在<body></body>之间加入:
<a href="###" onclick=settimeout(window.close(),3000)>3秒关闭本窗口</a>

加为首页
<SCRIPT>
function fnSet(){
oHomePage.setHomePage(location.href);
event.returnValue = false;
}
</SCRIPT>
<IE:HOMEPAGE ID="oHomePage" style="behavior:url(#default#homepage)"/>

模式窗口
父窗口
var url="aaa.jsp";
var

data=showModalDialog(url,null,"dialogHeight:400px;dialogHeight:600px;center:yes;help:No;status:no;resizab

le:Yes;edge:sunken");
if(data)
alert(data.value);

子窗口
var data=new Object();
data.value1="china";
window.returnValue=data;
window.close();

进行页面放大
<P onmouseover="this.style.zoom='200%'" onmouseout="this.style.zoom='normal'">
sdsdsdsdsdsdsdsds
</p>

通过style来控制隔行显示不同颜色
<style>
tr{
bgcolor:expression(this.bgColor=((this.rowIndex)%2==0 )? 'white' : 'yellow');
}
</style>
<table id="oTable" width="100" border="1" style="border-collapse:collapse;">
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
</table>

能输入的下拉框
<span>
<input name="Department1" id="Department1" style=" border-right:0;width:130" autocomplete="off">
<span style="width:150;overflow:hidden">
<select  style="width:150;margin-left:-130" onChange="Department1.value=value">
<option value=""></option>
<option value="asdfasfadf">asdfasfadf</option>
<option value="546546">546546</option></select>

自动关闭网页
<script LANGUAGE="javascript">
<!--
setTimeout('window.close();', 10000); //60秒后关闭
// -->
</script>
<p align="center">本页10秒后自动关闭,请注意刷新页面</p>
分享到:
评论

相关推荐

    常用js脚本收集javascript

    常用的js脚本收集 为网页设计提供方便 为txt文本格式自己可以复制使用

    13本网页设计技术手册

    13本网页设计技术手册,是我花了很多时间收集起来的,分享给大家了,全都是chm格式的,希望大家喜欢,下面是目录: Ajax入门手册.chm Cascading Style Sheet 2.0 中文手册.chm CSS 2.0样式表中文手册.chm CSS...

    JavaScript网页特效应用开发手册

    第五部分 动态网页设计 第11章 HTML与 Javascript的关系 11-1 Javascript的对象概念 11-2 两大浏览器对象概念的差异 11-3 事件 11-4 利用事件来触发 Javascnpt 第12章 Javascript的对话视窗 12-1 alerto 12-2 ...

    基于Vue的网页导航系统设计源码

    本设计源码提供了一个基于Vue的网页导航系统。项目包含92个文件,主要使用Vue、JavaScript、CSS和HTML编程语言。文件类型包括36个PNG图片文件、19个SVG文件、12个Vue组件文件、10个JavaScript脚本文件、4个JPG图片...

    常用JS图片滚动(无缝、平滑、上下左右滚动)代码

    本源代码收集了一些常用的网页图片滚动,无缝滚动,效果很平滑,包括上下左右四个方向的滚动,或许你现在用不上这些代码,不过先收藏起来以备后用哦。

    HTML5酷站源码网页HTML5模板源码代码(14个).rar

    01 HTML5 + PHP 清爽靓丽风格全站生成静态深度seo整站纯绿色代码...................06 大气时间轴图片滚动扁平化风格html5模板07 收集一些HTML5+CSS3 +JS的网页常用实例源代码08 灰色居左简洁大气的HTML5网站模板09...

    支持抓取javascript渲染的页面的简单实用高效的python网页爬虫抓取模块.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    DW代码片断

    这是我个人在平时收集的一些常用的 php js jquery css mysql 代码片断 hualunyi.com

    微信小程序开发SDK(用户授权、生成小程序码等方便易用).zip

    爬虫工程师需要设计相应的策略来应对这些挑战。 爬虫在各个领域都有广泛的应用,包括搜索引擎索引、数据挖掘、价格监测、新闻聚合等。然而,使用爬虫需要遵守法律和伦理规范,尊重网站的使用政策,并确保对被访问...

    pdd (拼多多) 爬虫 js 解密 anti_content 参数解密及全站抓取代码思路实现.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    jQueryUI常用功能实战.rar

    使用jQueryUI完成制作网站的大部分常用功能.  经过公司内部收集, 整理了一些经常使用javascript实现的功能. 实现这些功能的主角不是让人眼花缭乱的jQuery插件, 而是jQuery UI. 如果你还在为了一个小小的特效而...

    Vue.js+Node.js爬虫,GitHub数据的爬取与展示。.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    js逆向和爬虫.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    VC.NET备课笔记.rar

    第六讲 信息收集页面设计 一、信息收集页面 二、CheckBox控件 三、CheckBoxList控件 四、RadioButton控件 五、RadioButtonList控件 六、信息收集页面设计 第七讲 数据验证 一、数据验证概述 二、非空...

    Python爬虫进阶 JS 解密逆向实战.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    以Node.js基于express以及爬虫实现的视频资源后端.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    Node.js 爬虫示例 (for:百度百科).zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    JsUrl-java的爬虫.zip

    爬虫工程师需要设计相应的策略来应对这些挑战。 爬虫在各个领域都有广泛的应用,包括搜索引擎索引、数据挖掘、价格监测、新闻聚合等。然而,使用爬虫需要遵守法律和伦理规范,尊重网站的使用政策,并确保对被访问...

    仿简书nx+nodejs+nestjs6+express+mongodb+angular8+爬虫.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

    Python3 各种爬虫实战练习,JS 逆向、反反爬、验证码处理、登录签到抽奖、数据可视化.zip

    爬虫(Web Crawler)是一种自动化程序,用于从互联网上收集信息。其主要功能是访问网页、提取数据并存储,以便后续分析或展示。爬虫通常由搜索引擎、数据挖掘工具、监测系统等应用于网络数据抓取的场景。 爬虫的...

Global site tag (gtag.js) - Google Analytics