Home Web Front-end JS Tutorial A collection of common javascript coding techniques_form effects

A collection of common javascript coding techniques_form effects

May 16, 2016 pm 06:55 PM
javascript

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 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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

JavaScript and WebSocket: Building an efficient real-time image processing system JavaScript and WebSocket: Building an efficient real-time image processing system Dec 17, 2023 am 08:41 AM

JavaScript is a programming language widely used in web development, while WebSocket is a network protocol used for real-time communication. Combining the powerful functions of the two, we can create an efficient real-time image processing system. This article will introduce how to implement this system using JavaScript and WebSocket, and provide specific code examples. First, we need to clarify the requirements and goals of the real-time image processing system. Suppose we have a camera device that can collect real-time image data

See all articles