Home > Web Front-end > JS Tutorial > Detailed explanation of various JavaScript parameters

Detailed explanation of various JavaScript parameters

高洛峰
Release: 2016-11-25 14:11:49
Original
1637 people have browsed it

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, this event is generated.

Onselect: When After the text is highlighted, the file is generated

The text disappears when clicked and reappears when the focus is lost

2. Special color for web buttons

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

5. Button color changes

6. Flat input box

7. Make the window the specified size

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

8. Make the text scroll up and down

height=60>

Republic

http://www.webmake.cn/' ;return true">

10. You can click on the text to select the radio option


    < input type="radio" name="regtype" value="A03" id="A03">

11. You can write onclick events in the font of the text field

12. PrintPrint webpage

13. Line input box

class="line">

14. Display the last modified date of the document

15. The event can be triggered when the mouse moves over the text

;/script>

16. The page color can be determined according to the options on the webpage

background.html

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

Changing Background Colors< ;/B>


 

 

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秒自动关闭页面

< script language="JavaScript" >

function closeit() {

setTimeout("self.close()",10000)

}

< /script >

 

28.可以比较字符的大小

char=post.charAt(i);

if(!('0'<=char&&char<='9'))

 

29.将字符转化为数字

month = parseInt(char)

 

30.点击value非空的选项时转向指定连接

 

31.改变背景颜色

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

 

32.改变文字输入框的背景颜色

 

33.改变水平线的特征


 

34.传递参数的方式

 

35.页内跳转

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://ww"或者document.location.assign("http://guoguo.com")

 

45.在网页上显示实时时间

//

 

46.可以下载文件

document.location.href="http://www.php1.cn/">

 

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. You can change the format of the link on the page to make it double-line

Complete css

50. New frame

href="http://www.php1.cn/">

/a_13.html')">help

51. Write content to the file

<%@ page import="java.io.*" %>

<%

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. Read the file first and then write the file

<%@ page language = "java" %>

<%@ page contentType = "text/html; charSet=gb2312" %> ;

<%@ page import ="java.util.*" %>

<%@ page import ="java.lang.*" %>

<%@ page import ="javax .servlet.*" %>

<%@ page import ="javax.servlet.jsp.*" %>

<%@ page import ="javax.servlet.http.*" %>

<%@ page import="java.io.*" %>

eryrytry

<%

int count=0;

FileInputStream fi =new FileInputStream ("count.txt");

ObjectInputStream si= new ObjectInputStream (fi);

count =si.readInt();

count++;

out.print(count);

si.close();

FileOutputStream fo =new FileOutputStream ("count.txt");

ObjectOutputStream so= new ObjectOutputStream (fo);

so.writeInt(count);

so.close();

%>

53. Linear input box

54. You can change the background to a button shape and change the attributes by changing css

onmouseout=this.className='mouseout';>

color="#000000">Recorder

55. Press the CTRL and Q keys simultaneously

document.onkeydown=function()

🎜{🎜🎜if(event.ctrlKey&&event.keyCode== 81)🎜🎜{alert(1)}🎜🎜}//🎜🎜🎜

56.以下是一个完整的显示hint的代码,其思想是当鼠标停留是将div中的内容显示在鼠标出,当鼠标移出后在将该div隐

 

藏掉

---------------------------------------------------------------------------------------------------------

 

------------

--------------------------------- -------------------------------------------------- --------------------------

---------------------

57. Pop-up window

Method 1 : A window pops up when the browser reads the page;

Method 2: A window pops up when the browser leaves the page;

Method 3 : Call with a connection:

Note: The "#" used is a virtual connection.

Method 4: Use a button to call: When to load the script

58. Dynamically change the font size

function doZoom(size)

{

document.getElementByIdx_x('zoom').style.fontSize=size+'px'

}

function aa()

{

var newWin=window . open(url);

newWin.document.form1.text1.value=value1;

}Change the properties of the field on the pop-up window

opener.document.form2.text2.value=value2;Change the value of the field of the parent window

59. Determine what kind of browser it is

var name = navigator.appName;

if (name == "Microsoft Internet Explorer")

alert("IE");

else if (name = = "Netscape")

alert("NS");//

60.vbsscript OK box

//

61. Copy content to clipboard

function JM_cc(bb)

{

  var ob=eval_r ("document.form1."+bb);

ob.select();

js=ob.createTextRange();

js.execCommand("Copy");

}//

62 .Establish a database connection in java to retrieve data

public void init()

{

String url="jdbc:odbc:javadata";

try

{

Class.forName("sun.jdbc.odbc. JdbcOdbcDriver");

Connection con=DriverManager.getConnection(url,"sa","");//mssql database user SA and password

DatabaseMetaData dma=con.getMetaData();

System.out.println( "Connect to"+dma.getURL());

System.out.println(";Driver "+dma.getDriverName());

System.out.println(";Version "+dma.getDriverVersion() );

System.out.println("");

Statement stmt=con.createStatement();

ResultSet rs=stmt.executeQuery("select * from company.dbo.TB_NAME where number=1"); //Sql

rs.next();

String dispresult=rs.getString("name");

System.out.println(dispresult);// Instead, you can display it in Paint() or use AWT etc.

rs.close();

stmt.close();

con.close();

}

catch(SQLException ex)

{

System.out.println("! !!SQL Exception !!!");

while(ex!=null)

{

System.out.println("SQLState:"+ex.getSQLState());

System.out.println( "Message:"+ex.getMessage());

System.out.println("Vendor:"+ex.getErrorCode());

ex=ex.getNextException();

System.out.println( "");

}

}

catch(java.lang.Exception ex)

{

ex.printStackTrace();

}

}//

63. Minimize the window

window.blur()//

64. The path of the document

document.URL//

65. Execute a certain program regularly

setTimeout("change_color()" ,600);

66. Set as homepage

function makeHome(){

netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");

navigator.preference("browser.startup.homepage", location .href);

}//

67. Set as favorites

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");

}//

68. Judgment Whether cookies are available

navigator.cookieEnabled;//

69. Display a modal pop-up window with a page

function setbgcolor_onclick()

{

var color = showModalDialog("/mailpage/compose/colorsel. html",0,"help=0");

if (color != null)

{

document.compose.bgcolor.value = color;

}

}//

70.Truncate to two decimal places

var a=3454545.4454545;

alert(a.toFixed(2));//

71 .disable selection page to copy the text of

<script></p> <p>function noEffect() {</p> <p> with (event) {</p> <p>   returnValue = false;</p> <p>   cancelBubble = true; </p> <p> }</p> <p> return;</p> <p>}</p> <p>< /script></p> <p><body onselectstart="noEffect()" oncontextmenu="noEffect()">//</p> <p> </p> <p>72. Shield the right-click menu</p> <p>oncontextmenu="event.returnValue = false"//</p> <p> </p> <p>73. Disable event bubbling</p> <p>event.cancelBubble = true//</p> <p> </p> <p>74. Disable opening the input method in the input box</p> <p><input style="ime-mode: disabled">//</p> <p> </p> <p>75. Block Chinese characters and spaces</p> <p><input name="txt"><input type="submit" onClick="alert(!/[^ -}]|/s/.test(txt.value ; "Scripting.FileSystemObject");</p><p> alert(fso.FileExists(filespec));</p><p>}</p><p>}</p><p>Select image<input type=file name=f1><p></p> <p><input type= "submit" onClick="Exists(f1.value)">//</p> <p> </p> <p>77. Get the text selected in the current text box</p> <p><input onmouseup="alert(document.selection.createRange().text )" value=123>//</p> <p> </p> <p>78. Jump to the target page and cannot return</p> <p><a href="http://www.php1.cn/"></p> <p> </p> <p> </p> <p> 79. Get which row of the table the current row is </p> <p><script></p> <p>function getrow(obj)</p> <p>{</p> <p> if(event.srcElement.tagName=="TD"){</p> <p> curRow=event. srcElement.parentElement;</p> <p> alert("This is the "+(curRow.rowIndex+1)+"row");</p> <p> </p> <p> }</p> <p>}</p> <p></script>

width="20%">  

  

  td width="20%">

 
//

80. Delete a certain row of the table, xx represents a certain row, the following The index is calculated from 0

document.all.myTable.deleteRow(xx)//

81. Dynamically add rows to the table



4人

 

backdepth='15pt' on='true'/>



4人

 

backdepth='15pt' on='true'/>//

 

101.饼图

 

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">

 

CoordSize='10,10' strokecolor='white' fillcolor='#ffff33'>

 

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">

 

CoordSize='10,10' strokecolor='white' fillcolor='#ff9933'>

 

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">

 

CoordSize='10,10' strokecolor='white' fillcolor='#3399ff'>

 

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">

 

CoordSize='10,10' strokecolor='white' fillcolor='#99ff33'>

 

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">

 

CoordSize='10,10' strokecolor='white' fillcolor='#ff6600'>

 

onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href="http://www.php1.cn/">

 

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. It is a special container, you can install a web page if you want