SoFunction
Updated on 2025-04-06

JavaScript tips  Super recommended page 1/5

Event source object
 
 
Capture and release
();  
();  
Event button
 
 
 
 
Event return value
 
Mouse position
 
 
Form activity elements
 
Binding events
(); 
Access form elements
("txt").focus(); 
("txt").select(); 
Form Command
 
Form COOKIE
 
Menu Events
 
Create elements
("SPAN");  
Obtain elements according to the mouse:
(,).tagName=="TD 
(,).appendChild(ms)  
Form picture
[Index]
Form event binding
=scrollwindow; 
Elements
document.form.elements[index]
Object binding event
('onclick',a); 
Number of plugins
 
Take variable type
typeof($js_libpath) == "undefined" 
Pull down box
drop-down box.options[index]
Pull down box.
Find a Object
("r1"); 
(id); 
Timed
timer=setInterval('scrollwindow()',delay); 
clearInterval(timer); 
UNCODE encoding
escape() ,unescape 
Parent object
(dhtml) 
(dom) 
Exchange table rows
(2,1) 
Replace CSS
 = ""; 
Side by side display
display:inline 
Hide focus
hidefocus=true 
Line breaks according to width
style="word-break:break-all" 
Automatic refresh
<meta HTTP-EQUIV="refresh" CONTENT="8;URL="> 
Simple email
<a  href="mailto:aaa@?subject=ccc&body=xxxyyy">  
Quickly go to location
(true) 
Anchor
<a name="first"> 
<a href="#first">anchors</a> 
Web page delivery parameters
(); 
Editable
=true 
Execute menu commands
 
Double byte characters
/[^\x00-\xff]/ 
Chinese characters
/[\u4e00-\u9fa5]/ 
Let English strings automatically wrap lines beyond the table width
word-wrap: break-word; word-break: break-all; 
Transparent background
<IFRAME src="" width=300 height=180 allowtransparency></iframe> 
Get style content
 
HTML tags
 
The first style tag
[0] 
The first style in the style tag
[0].rules[0] 
Prevent the page from resetting to the top of the page when clicking an empty link.
<a href="javascript:function()">word</a> 
Previous page source
asp: 
("HTTP_REFERER") 
javascript: 
 
Free memory
CollectGarbage(); 
Right-clicking is prohibited
 = function() { return false;} 
Saving is prohibited
<noscript><iframe src="*.htm"></iframe></noscript> 
The selection of <body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="()" oncopy="()" onbeforecopy="return false"onmouseup="()>
No paste
<input type=text onpaste="return false"> 
Address bar icon
<link rel="Shortcut Icon" href=""> 
It is best to keep the name 16*16 16 colors, put it in the root directory of the virtual directory.
Favorites Bar Icon
<link rel="Bookmark" href=""> 
View source code
<input type=button value=View the web source code onclick=" = 'view-source:'+ '/'">
Close input method
<input style="ime-mode:disabled"> 
Automatically select all
<input type=text name=text1 value="123" onfocus="()"> 
ENTER key allows the cursor to move to the next input box
<input onkeydown="if(==13)=9"> 
Default value of text box
<input type=text value="123" onfocus="alert()"> 
title line wrap
 = "123&#13sdfs&#32" 
Obtain the microseconds represented by time
var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime() 
Is the window closed?
 
checkbox flat
<input type=checkbox style="position: absolute; clip:rect(5px 15px 15px 5px)"><br> 
Get selected content
().duplicate().text 
Automatic completion function
<input  type=text  autocomplete=on>Open this function
<input  type=text  autocomplete=off> Turn off this function
Window Maximization
<body onload="( - 4,-50);(-4,-4)"> 
No close button IE
("", "meizz", "fullscreen=7"); 
Unified encoding/decoding
alert(decodeURIComponent(encodeURIComponent("http://hello.com?as= hehe")))
encodeURIComponent pairs ":", "/", ";" and "?" are also encoded
Table row instructions
<tr onmouseover="='#f0f0f0'" onmouseout="='#ffffff'"> 
Various sizes
Copy the codeThe code is as follows:

s  +=  "\r\nVisible area width of the web page: "+  ;
s  +=  "\r\nVisible area height of the web page: "+  ;
s  +=  "\r\nVisible area height of the web page: "+   +"  (including the width of the edge)";
s  +=  "\r\nVisible area height of the web page: "+   +"  (including the width of the edge)";
s  +=  "\r\nThe full text width of the web page: "+  ;
s  +=  "\r\nThe full text of the web page is high: "+  ;
s  +=  "\r\nThe web page was rolled off high: "+  ;
s  +=  "\r\nThe left of the web page being rolled off: "+  ;
s  +=  "\r\nOn the main part of the web page: "+  ;
s  +=  "\r\nThe left part of the web page text: "+  ;
s  +=  "\r\nThe high screen resolution: "+  ;
s  +=  "\r\nWidth of screen resolution: "+  ;
s  +=  "\r\nThe screen available workspace height: "+  ;
s  +=  "\r\nThe screen available workspace width: "+  ;

12345Next pageRead the full text