Common JS Code

Source: Internet
Author: User

1. prevent being owed
<Script language = "JavaScript">
<! --
If (window! = Window. Top) {top. Location. href = location. href ;}
// -->
</SCRIPT>

2. Always carry the framework
<Script language = "JavaScript">
<! --
If (window = Top) top. Location. href = "frames.htm ";
// -->
</SCRIPT>
Note: frames.htm Is Your webpage. This is also a method to protect the webpage.

3. The webpage cannot be saved
<NoScript> <IFRAME src = *. html> </iframe> </NoScript>
Note: <noscirpt> is widely used, one of which can invalidate JS ads.

4. Automatic jump
InSource code<Head>... </Head> join
<Meta http-equiv = "refresh" content = "8; url = http://www.liqun.net">
Note: content = "8" indicates that the URL is refreshed in 8 seconds.

5. Open the window to maximize the value immediately
<Script language = "JavaScript">
<! -- Begin
Self. moveTo (0, 0)
Self. resizeTo (screen. availwidth, screen. availheight)
// End -->
</SCRIPT>

6. Add background music
<Bgsound src = "mid/min1.mid" loop = "-1"> only applicable to IE
<Embed src = "music. Mid" autostart = "true" loop = "true" hidden = "true"> applicable to both Netscape and IE

7. webpage transition mode
<Meta http-equiv = "Page-Exit" content = "revealtrans (duration = 3, transition = 5)">
The duration value is the dynamic transition time of the webpage, in seconds.
Transition is a transitional mode. Its value ranges from 0 to 23, corresponding to 24 transition modes respectively. See the following table:
0-box contraction 1-box radiation
2 circular contraction 3 circular radiation
4 From bottom up 5 from top down
6 from left to right 7 from right to left
8 vertical blinds 9 horizontal blinds
10 horizontal blinds 11 vertical blinds
12 dissolve at will 13 expand from left and right ends to the middle
14 expand from the center to the left and right sides 15 expand from the up and down ends to the middle
16. expand from the middle to the bottom. 17. expand from the top right to the bottom left.
18 expand from bottom right to top left 19 from top left to bottom right
20. Expand the 21 horizontal lines from the lower left corner to the upper right corner.
22 vertical linear expansion 23 random generation of a transitional mode

Webpage transition mode instance:
<Meta http-equiv = "Page-Enter" content = "blendtrans (duration= 0.5)"/>
<Meta http-equiv = "Page-Exit" content = "blendtrans (duration= 0.5)"/>

8. Control the horizontal and vertical scroll bars
<Body style = "overflow-Y: hidden"> remove the X axis.
<Body style = "overflow-X: hidden"> remove the Y axis.
<Body scroll = "no"> hide

9. Add to favorites:
<A href = "Java Script: window. External. AddFavorite ('HTTP: // www.liqun.net ', www.liqun.net');"> Add to favorites </a>
<A style = "cursor: hand"
Onclick = "window. External. AddFavorite (location. href, document. Title);"> Add to favorites </a>

10. Set as homepage:
<A href = # onclick = This. style. behavior = 'url (# default # homepage) '; this. setHomePage ('HTTP: // www.liqun.net ');> set as homepage </a>
<A style = "cursor: hand"
Onclick = "This. style. Behavior =" URL (# default # homepage )";
This. setHomePage (http://www.liqun.net/); ">"> set to home </a>

11. Special Effect display of the status bar
<Script language = JavaScript> kstatus ();
Function cm (){
Self. Status = "liqun.net ";
SetTimeout ("cm ()", 0 );
} </SCRIPT>

12. Open the website and add to Favorites now
<SCRIPT>
If (navigator. appname = 'Microsoft Internet Explorer '& parseint (navigator. appversion)> = 4)
{
Window. External. AddFavorite ('HTTP: // www.liqun.net ', 'aliyun ');
}
</SCRIPT>

13. No prompt is displayed when the window is closed.
<A href = "#" _ fcksavedurl = "" # "" onclick = "expose Crip: window. Opener = NULL; window. Close ()"> close </a>

14. Gradient of background color
Filter: progid: DXImageTransform. Microsoft. gradient (startcolorstr = '# ffffff', endcolorstr =' # f6f9fe '', gradienttype = '0 ')

15. Transparent background color
Filter: alpha (opacity = 75)

16. pop-up window properties
<Script language = "JavaScript">
<! --
Window. open ('page.html ', 'newwindow', '1970, width = 100, Top = 0, Left = 0, toolbar = No, menubar = No, scrollbars = No, resizable = No, location = No, status = no ')
-->
</SCRIPT>

<Script language = "JavaScript"> the JS script starts;
Window. Open command to pop up a new window;
'Page.html 'name of the pop-up window;
'Newwindow' indicates the name of the pop-up window (not the file name). It is optional and can be replaced by null;
100 window height;
Width = 400 window width;
Top = the pixel value between the 0 window and the top of the screen;
Left = 0 the pixel value between the window and the left of the screen;
Toolbar = No indicates whether to display the toolbar. Yes indicates display;
Menubar and scrollbars indicate the menu bar and scroll bar.
Resizable = No: whether to change the window size. Yes: Yes;
Location = No indicates whether the address bar is displayed. Yes indicates yes;
Status = No whether to display the information in the status bar (usually the file has been opened), yes is allowed;
</SCRIPT> end of JS script

17. Background Color Conversion
<SCRIPT type = text/JavaScript>
Function scbg (objref, state ){
Objref. style. backgroundcolor = (1 = State )? '# Eeeeeee':' # ffff ';
Return;
}
</SCRIPT>
<Div onmouseover = "scbg (this, 1);" onmouseout = "scbg (this, 0);">

18. Expand and hide a table
<Script language = "VBScript">
Function showhide (showobject)
If document. All (showobject). style. Display = "" then
Document. All (showobject). style. Display = "NONE"
Else
Document. All (showobject). style. Display = ""
End if
End Function
</SCRIPT>
Application Results
<A href = 'vbscript: showhide ("Cont") '> Expand or hide </a> <br>
<Div id = "Cont"> control content range </div>
Use the link to control the expansion or hiding of ID = "Cont"

19. scroll bar color
Body {
Scrollbar-face-color: # ffffff;
Scrollbar-Highlight-color: # ffffff;
Scrollbar-shadow-color: # ffffff;
Scrollbar-3dlight-color: # ffffff;
Scrollbar-arrow-color: # ffb900;
Scrollbar-track-color: # eeeeee;
Scrollbar-darkshadow-color: # ffffff ;}

Color of the protruding section of the SCROLLBAR-FACE-COLOR scroll bar
Color of the blank part of the SCROLLBAR-HIGHLIGHT-COLOR scroll bar
Color of the SCROLLBAR-SHADOW-COLOR stereo scroll bar shadow
The color of the bright side of the SCROLLBAR-3DLIGHT-COLOR scroll bar
SCROLLBAR-ARROW-COLOR up and down button up arrow color
Background Color of the SCROLLBAR-TRACK-COLOR scroll bar
SCROLLBAR-DARKSHADOW-COLOR scroll bar strong shadow color
Basic Color of the SCROLLBAR-BASE-COLOR scroll bar

20. view the IP address. asp:
= Request. servervariables ("remote_addr ")

21. Script showing the current time
<Script language = VBScript> document. Write now </SCRIPT>

22. Script showing the last modification time
<SCRIPT> document. Write (document. lastmodified) </SCRIPT>

23. Join the channel
<A href = javascript: window. External. addchannel ("Typhoon. CDF")> Add channel </a>

24. Press the F12 key to return to the home page.
<SCRIPT> function look (){
If (event. keycode = 123) {document. Location. href = http://www.liqun.net /}
}
If (document. onkeydown = NULL)
{Document. onkeydown = Look}
</SCRIPT>

25. Long line feed
Word-break: Break-all;

26. The content of the same element does not wrap.
White-space: nowrap;

27. uppercase letters
Text-transform: Capitalize;

28. Page Width Control
<Div id = "divmain">
<! -- [If IE]>
<SCRIPT>
VaR objmain = Document. getelementbyid ("divmain ");
Function updatesize () {var bodyw = Invalid invalid Doc ument. body. offsetwidth; If (bodyw <= 790) objmain. style. width = "760px"; else if (bodyw> = 1016) objmain. style. width = "980px"; else objmain. style. width = "100% ";}
Updatesize (); window. onresize = updatesize;
</SCRIPT>
</Div>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.