search
HomeWeb Front-endJS TutorialA collection of common javascript coding techniques_form effects

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
Javascript Data Types : Is there any difference between Browser and NodeJs?Javascript Data Types : Is there any difference between Browser and NodeJs?May 14, 2025 am 12:15 AM

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScript Comments: A Guide to Using // and /* */JavaScript Comments: A Guide to Using // and /* */May 13, 2025 pm 03:49 PM

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python vs. JavaScript: A Comparative Analysis for DevelopersPython vs. JavaScript: A Comparative Analysis for DevelopersMay 09, 2025 am 12:22 AM

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Python vs. JavaScript: Choosing the Right Tool for the JobPython vs. JavaScript: Choosing the Right Tool for the JobMay 08, 2025 am 12:10 AM

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript: Understanding the Strengths of EachPython and JavaScript: Understanding the Strengths of EachMay 06, 2025 am 12:15 AM

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScript's Core: Is It Built on C or C  ?JavaScript's Core: Is It Built on C or C ?May 05, 2025 am 12:07 AM

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript Applications: From Front-End to Back-EndJavaScript Applications: From Front-End to Back-EndMay 04, 2025 am 12:12 AM

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Python vs. JavaScript: Which Language Should You Learn?Python vs. JavaScript: Which Language Should You Learn?May 03, 2025 am 12:10 AM

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

See all articles

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 Article

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool