Home  >  Article  >  Web Front-end  >  A collection of common javascript coding techniques_form effects

A collection of common javascript coding techniques_form effects

WBOY
WBOYOriginal
2016-05-16 18:55:43946browse
1. Text box focus problem
onBlur: This event is generated when the input focus is lost
onFocus: When the input gains focus, the file is generated
Onchange: When the text value changes, Generate this event
Onselect: When the text is highlighted, generate this file
The text disappears when clicked and reappears when the focus is lost
2. Special features of web buttons Color
style="background-color:rgb(235,207,22)">
3. The color changes when the mouse moves in and out
onMouseOver =this.style.color="red" class="button">
4. Flat button
BACKGROUND-COLOR: #E8E8FF; color:#666666" name="submit">
5. Button color change

6. Flat input box

7. Make the window the specified size

8. Make the text scroll up and down
height=60>



Republic<script> <BR>window.resizeTo(300,283); <BR></script>

9.状态栏显示该页状态

10.可以点击文字实现radio选项的选定


    


11.可以在文字域的font写onclick事件
12.打印
打印网页
13.线型输入框
class="line">
14.显示文档最后修改日期

15.可以在鼠标移到文字上时就触发事件





link


16.可以根据网页上的选项来确定页面颜色


background.html

<script> <BR><!-- <BR>function bgChange(selObj) { <BR>newColor = selObj.options[selObj.selectedIndex].text; <BR>document.bgColor = newColor; <BR>selObj.selectedIndex = -1; <BR>} <BR>//--> <BR></script>

Changing Background Colors







17.将按钮的特征改变

  本例按钮的代码如下:
onmouseout="this.className='style1'" class="style1">
18.改变按钮的图片.

  本例的按钮代码如下:
onmouseout="this.className='style3'" class="style3">
19.打印页面

20.可以直接写html语言
document.write("");
21.改变下拉框的颜色
>guoqiang99859
25.layer2为组件的ID,可以控制组件是否可见
document.all.item('Layer2').style.display = "block";
document.all.item('Layer2').style.display = "none";//
26.将页面加入favorite中
//
27.过10秒自动关闭页面

function closeit() {
setTimeout("self.close()",10000)
}

28.可以比较字符的大小
char=post.charAt(i);
if(!('0'29.将字符转化为数字
month = parseInt(char)
30.点击value非空的选项时转向指定连接

31.改变背景颜色
onmouseout="this.bgColor='#FAFBFC';">
32.改变文字输入框的背景颜色


33.改变水平线的特征


34.传递参数的方式
8
35.页内跳转
1
2
3
4
5
6
7
dfdf
dfdf//
36.两个按键一起按下
if(event.ctrlKey && window.event.keyCode==13)//
37.刷新页面
javascript:this.location.reload()//
38.将网页的按钮使能





39.文字移动

40.双击网页自动跑
//
41.后退

42.前进

43.刷新

44.转向指定网页
document.location=http://blog.csdn.net/lxs5i5j/archive/2007/01/22/"http://ww"或者document.location.assign(http://blog.csdn.net/lxs5i5j/archive/2007/01/22/"http://guoguo.com")
45.在网页上显示实时时间
//
46.可以下载文件
document.location.href="目标文件"//
47.连接数据库
import java.sql.*;
String myDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(myDBDriver);
Connection conn=DriverManager.getConnection("jdbc:odbc:firm","username","password");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
rs.getString("column1");//
48.可以直接在页面“div”内写下所需内容

//
49.可以改变页面上的连接的格式,使其为双线

A:link {text-decoration: none; color:#0000FF; font-family: 宋体} A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}
A:hover {text-decoration: underline overline; color: FF0000}

帮助A:link {text-decoration: none; color:#0000FF; font-family: 宋体}
A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}
A:hover {text-decoration: underline overline line-through; color: FF0000}
TH{FONT-SIZE: 9pt} TD{FONT-SIZE: 9pt}
body {SCROLLBAR-FACE-COLOR: #A9D46D; SCROLLBAR-HIGHLIGHT-COLOR: #e7e7e7;SCROLLBAR-SHADOW-COLOR:#e7e7e7; SCROLLBAR-3DLIGHT-COLOR: #000000; LINE-HEIGHT: 15pt; SCROLLBAR-ARROW-COLOR: #ffffff;
SCROLLBAR-TRACK-COLOR: #e7e7e7;}
INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE:
9pt; BORDER-LEFT-COLOR: #cccccc;
BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc;
PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}
DIV,form ,OPTION,P,TD,BR{FONT-FAMILY: 宋体; FONT-SIZE: 9pt}
textarea, select {border-width: 1; border-color: #000000; background-color: #efefef; font-family: 宋体;
font-size: 9pt; font-style: bold;}
.text { font-family: "宋体"; font-size: 9pt; color: #003300; border: #006600 solid; border-width: 1px 1px
1px 1px}
完整的css
50.新建frame
href="javascript:newframe('http://www.163.net/help/a_little/index.html','http://www.163.net/help/a_little
/a_13.html')">

51.向文件中写内容
String str = "print me"; //always give the path from root. This way it almost always works.
String nameOfTextFile = "/usr/anil/imp.txt"; try
{ PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));
pw.println(str); //clean up
pw.close(); }
catch(IOException e)
{ out.println(e.getMessage());
}
%>
52.先读文件再写文件









eryrytry int count=0;
FileInputStream fi =new FileInputStream ("count.txt");
FileOutputStream fo =new FileOutputStream ("count.txt");
ObjectOutputStream so= new ObjectOutputStream (fo);
so.writeInt(count);
so.close();
%>
53.直线型输入框
54.可以将背景改为按钮性状,通过改变css改变属性 onmouseout=this.className='mouseout';>
color="#000000">录音笔

.mouseoverbt {

background-image: url(file:///c|/">

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

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

87.本地快捷键

网上邻居

我的电脑<script> <BR>window.resizeTo(300,283); <BR></script> <script> <BR><!-- <BR>function bgChange(selObj) { <BR>newColor = selObj.options[selObj.selectedIndex].text; <BR>document.bgColor = newColor; <BR>selObj.selectedIndex = -1; <BR>} <BR>//--> <BR></script>我的文档 <script> <BR>var contents='<style>body,td{font:menu}img{cursor:hand}'; <BR>contents+='<title>你要关闭我吗'; <BR>contents+='<body bgcolor=menu>'; <BR>contents+='<table width=100% height=100% border=0>'; <BR>contents+='<tr><td align=center>'; <BR>contents+='你要关闭我吗?<br>'; <BR>contents+='<img src=http://www.aspxclub.com/UploadFile/Material/1/1281.gif onclick=self.close() alt="A collection of common javascript coding techniques_form effects">'; <BR>contents+='<img src=http://www.aspxclub.com/UploadFile/Material/1/1282.gif onclick=self.close() alt="A collection of common javascript coding techniques_form effects">'; <BR>contents+='</script>
';
showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no")
document.write(contents);
回收站 target="_blank">控制面板 拨号网络(windows 2000)
88.IE菜单
//改变按钮上的图片
//创建新连接
//打印
//另存为htm
//另存为txt
document.execCommand("SaveAs")//保存为
document.execCommand('undo')//撤销上一次操作
89.web对话框
<script> <BR>var contents='<style>body,td{font:menu}img{cursor:hand}'; <BR>contents+='<title>你要关闭我吗'; <BR>contents+='<body bgcolor=menu>'; <BR>contents+='<table width=100% height=100% border=0>'; <BR>contents+='<tr><td align=center>'; <BR>contents+='你要关闭我吗?<br>'; <BR>contents+='<img src=http://www.aspxclub.com/UploadFile/Material/1/1281.gif onclick=self.close() alt="A collection of common javascript coding techniques_form effects">'; <BR>contents+='<img src=http://www.aspxclub.com/UploadFile/Material/1/1282.gif onclick=self.close() alt="A collection of common javascript coding techniques_form effects">'; <BR>contents+=''; <BR>showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no") <BR>document.write(contents); <BR></script>//
90.取第x,y的值
//
91.向新打开的网页上写内容
newwin=window.open('about:blank','','top=10');
newwin.document.write('');//
93.返回
javascript:history.go(-2);//
94.将页面上选中的内容复制到剪贴板
abcdefg
onclick="window.clipboardData.setData('text',document.selection.createRange().text);" value='复制页面选中
的字符'>//
95.将页面上选中的内容复制到剪贴板
kjhkjhkhkj////
96.鼠标移到下拉框时自动全部打开
//
97.获得本机的文件
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f1 = fso.GetFile("C:\\bsitcdata\\ejbhome.xml");
alert("File last modified: " + f1.DateLastModified); //
98.判断客户端是否是IE浏览器
因为 document.all 是 IE 的特有属性,所以通常用这个方法来判断客户端是否是IE浏览器 ,document.all?1:0;
99.创建新的下拉框选项
new Option(text,value)这样的函数//
100.在页面上画柱状图



%12
4人backdepth='15pt' on='true'/>


%12
4人backdepth='15pt' on='true'/>
//
101.饼图





onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com'
CoordSize='10,10' strokecolor='white' fillcolor='#ffff33'>

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com'
CoordSize='10,10' strokecolor='white' fillcolor='#ff9933'>

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com'
CoordSize='10,10' strokecolor='white' fillcolor='#3399ff'>

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com'
CoordSize='10,10' strokecolor='white' fillcolor='#99ff33'>

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com'
CoordSize='10,10' strokecolor='white' fillcolor='#ff6600'>

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com'
CoordSize='10,10' strokecolor='white' fillcolor='#ff99ff'>




style='fontsize:2'>asp技术/>

style='fontsize:2'>php/>

style='fontsize:2'>jsp/>

style='fontsize:2'>c#写的.netWEB程序/>

vb.net
写的.netWEB程序
/>


xml技术
/>



style="border-collapse: collapse" bordercolor="#CCCCCC" width="100%" ID="Table1">



 

//
102.是一个特殊的容器,想装个网页都行
//button
103.外部的html代码
event.srcElement.outerHTML//
104.标识当前的IE事件的触发器
event.srcElement和event.keyCode//
105.事件类型
event.type//
106.动态改变类型

//
107.页面翻转
//
Statement:
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