Typical JS Code

Source: Internet
Author: User
JS classic Code

1. the right-click dialog box is completely blocked, and no shortcut menu is available.

<Body oncontextmenu = "window. event. returnvalue = false">

It can also be used in the table framework of a webpage.

<Table border oncontextmenu = return (false)> <TD> NO </table>

2. Cancel selection and prevent Replication

<Body onselectstart = "Return false">

3. Do not paste
<Body onpaste = "Return false">

4. Prevent Replication
<Body oncopy = "Return false;" oncut = "Return false;">

5. Replace the IE icon in front of the address bar
<LINK rel = "shortcut icon" href = "favicon. ICO">
Note: The favicon. ICO file is created. You can create an image in FW to create a small icon on your own site. Then change the file attribute to * in ACD see *. ICO, and then perform *. the ICO file is uploaded to your server directory and can be implemented using the above Code. When someone else logs on to your site, your custom icon is used in the address bar.

6. You can display your icons in the favorites folder.
<LINK rel = "bookmark" href = "favicon. ICO">
Note: The production method is the same as above. The display method is different. This is the personal icon displayed when someone else adds Your webpage address to favorites. Pp.

7. Disable the Input Method
<Input style = "ime-mode: Disabled">
Note: This code is used when submitting a table. That is, other input methods cannot be used when data is input.

8. 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.

9. Prevent Frame
<Script language = JavaScript> <! --
If (top. location! = Self. Location) top. Location = self. location;
// --> </SCRIPT>

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

11. Check the source file
<Input type = button value = view webpageSource code
Onclick = "window. Location = 'view-Source: '+ http://www.wuchongyuan.com';">

12. cookie script record, which is very useful
function get_cookie (name) {
var search = Name + "="
var returnvalue = "";
If (statements. cookie. length> 0) {
offset = documents. cookie. indexof (Search)
If (offset! =-1) {// If Cookie exists
Offset + = search. length
// SET index of beginning of value
end = documents. cookie. indexof (";", offset);
// SET index of end of cookie value
If (END =-1)
end = documents. cookie. length;
returnvalue = Unescape (documents. cookie. substring (offset, end)
}< BR >}< br> return returnvalue;
}< br> function loadpopup () {
If (get_cookie ('popped') = '') {
openpopup ()
events. cookie = "popped = yes"
}< BR >}< br> Note: The above is the JS Code. Please add the start and end operators by yourself.

13. Use of the internal framework <IFRAME>
The format of the IFRAME tag is:
<IFRAME src = "url" width = "X" Height = "X" scrolling = "[Option]" frameborder = "X"
Name = "Main"> </iframe>
SRC: file path, which can be an HTML file or text or ASP file; width and height: width and height of the "internal framework" area;
Scrolling: when the specified HTML file of SRC is not displayed in the specified area, the scroll option is displayed. If it is set to no, no scroll bar is displayed. If it is set to Auto:, a scroll bar is automatically displayed; if yes, it will be displayed. frameborder: The Border width of the area. It is usually set to 0 to make the "internal framework" and adjacent content converge.
Name: Framework name, used for identification.
For example, if you want to use the parent framework to control the internal framework, you can use: Target = "framework name" to control it.
Example: <IFRAME name = "mm" src = "http://www.wuchongyuan.com ";; width = "100%" Height = "100%" marginwidth = "0" marginheight = "0" hspace = "0" vspace = "0" frameborder = "0" scrolling = "no"> </iframe>

14. Automatic jump
In the source code, <Meta http-equiv = "refresh" content = "3; url = http://www.wuchongyuan.com; charset = gb2312">
Note: content = "3 indicates that the URL is refreshed in 3 seconds.

15. How to change the Mouse shape of a link
You just need to add this code to the link.
Or keep up with the above and write it in CSS.
Style = "cursor: Hand" style = "cursor: crosshair"
Style = "cursor: Text" style = "cursor: Wait"
Style = "cursor: Move" style = "cursor: help"
Style = "cursor: E-resize" style = "cursor: N-resize"
Style = "cursor: NW-resize" style = "cursor: W-resize"
Style = "cursor: S-resize" style = "cursor: Se-resize"
Style = "cursor: Sw-resize"
You only need to add the above Code to the connection or the style area of the page to diversify the mouse.

16. Full Screen Display
<Form>
<Div align = "center">
<Input type = "button" name = "fullscreen" value = "full screen" onclick = "window. open (document. location, 'Big ', 'fullscreen = yes') ">
</Div>
</Form>
Put it in the <body> area.

17. Set as Homepage
<Script language = "JavaScript">
<! --
Function defaul_home (){
This. Home. style. Behavior = 'url (# default # homepage) '; this. Home. setHomePage (http://myok.bokee.com /';);
}
VaR focusok = false;
If (navigator. appname = "Netscape "){
Focusok = true;
}
Vers = navigator. appversion;
If (navigator. appname = "Microsoft Internet Explorer "){
Pos = vers. lastindexof ('.');
Vers = vers. substring (pos-1, vers. Length );
}
Proper_version = parsefloat (VERs );
If (proper_version> = 5 ){
Focusok = true;
}
Function launchstock1 (htmlurl ){
VaR stock = Window. open (htmlurl, "stock", "Top = 2, Left = 2, toolbar = No, location = No, directories = No, status = No, menubar = No, scrollbars = Yes,
Resizable = No, width = 700, Height = 510 ");
If (focusok ){
Stock. Focus ();
}
Return true;
}
Function launchstock (){
VaR stock = Window. open ("", "stock", "Top = 2, Left = 2, toolbar = No, location = No, directories = No, status = No, menubar = No, scrollbars = Yes,
Resizable = No, width = 700, Height = 510 ");
If (focusok ){
Stock. Focus ();
}
Return true;
}
// -->
</SCRIPT>
<A href = "#" name = "home" onclick = "defaul_home (); "Title =" = Wu chongyuan marketing website = "> set as homepage </a>

18. Here is the code to add to favorites
<A href = "#" onclick = "window. external. addFavorite (http://www.wuchongyuan.com ';. '-= Wu chongyuan marketing website =-') "target =" _ Self "Title ="-= Wu chongyuan marketing =-"> Add to favorites </a>

19. Flash Image Effect
Add the following code to the <Script language = "JavaScript">
<! --
Function makevisible (cur, which ){
If (which = 0)
Cur. Filters. Alpha. Opacity = 100
Else
Cur. Filters. Alpha. Opacity = 20
}
// -->
</SCRIPT>
Add the following code to the <body> Area
// modify the image address.

20. Scroll down the background image
<Body scroll = "no" background = "images/bg.jpg" link = "#00ff00" alink = "# ff0000" vlink = "#00ff00" bgcolor = "#000080" topmargin = "8">
<Script language = "JavaScript">
VaR backgroundoffset = 0;
VaR bgobject = eval_r ('document. body ');
Function scrollbg (maxsize) {backgroundoffset = backgroundoffset + 1;
If (backgroundoffset> maxsize) backgroundoffset = 0;
Bgobject. style. backgroundposition = "0" + backgroundoffset ;}
VaR scrolltimer = Window. setinterval ("scrollbg (410)", 20)
</SCRIPT>

21. Rolling Effects
<Marquee onmouseover = "this. stop () "onmouseout =" this. start () "scrollamount =" 2 "scrolldelay =" 0 "ction =" up "width =" 330 "Height =" 120 "border =" 0 "align =" center "id =" marquee1 ">
Welcome to Wu chongyuan marketing website
Our address http://www.wuchongyuan.com
</Marquee>

22. Make the background image not scroll

Internet Explorer supports a body attribute bgproperties, which can prevent the background from rolling:
<Body background = "Image File" bgproperties = "fixed"> "〉

23. Make your webpage unable to be saved

<NoScript> <IFRAME src = *> </iframe> </NoScript>

24. Transparent background of documents in the IFRAME framework

<IFRAME src = "about: <body style = 'background: transparent'>" allowtransparency> </iframe>

25. Right-click prohibited:

<Body oncontextmenu = "Return false" ondragstart = "Return false" onselectstart = "Return false" onselect = "document. selection. empty () "oncopy =" document. selection. empty () "onbeforecopy =" Return false "onmouseup =" document. selection. empty () ">

26. Will the page be automatically refreshed immediately?
<Meta http-equiv = "refresh" content = "120; url = http://www.wuchongyuan.com">
Http://www.wuchongyuan.com, this is your own web site.

27. Three Methods to hide the IFRAME scroll bar:

1. Set IFRAME scrolling = "no"
2. Apply overflow: hidden to the contained page body
3. Add scroll = "no" to the body tag of the contained page"

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

29. Scroll
<Marquee direction = up Height = 146 onmouseout = start () onmouseover = stop () scrollamount = 4> </marquee>

30. Thin line Separator
<HR noshade size = 0 color = # c0c0c0>

31. Excessive
<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

32. How do I control the explicit hiding of 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

33. The format for adding comments is:
<〈! -[Comment...] --> --〉

34. How can I add an e-mail link to the webpage and display the predefined topic?
<A href = "wuchongyuan@126.com? Subject = topic "> "〉...... </A> 〉

35. Define the keyword of this webpage. You can add the following code to <Meta name = "keywords" content = "Wu chongyuan marketing website"> "〉
The content contains keywords. You can set them by yourself.
Here is a tip. You can repeat a word to improve the ranking position of your website, such:
<Meta name = "keywords" content = "Wu chongyuan marketing"> "〉

36. Add to favorites:
<A href = "Java Script: window. External. AddFavorite (http://www.wuchongyuan.com ', 'HTTP: // www.wuchongyuan.com');"> Add to favorites </a> 〉

37. Set as homepage:
<A href = # onclick = This. style. Behavior = 'url (# default # homepage) '; this. setHomePage (http://www.wuchongyuan.com);> set as home </a> 〉

38. Customize the small icon in front of the browser address bar:
A: Add the following statement to the <LINK rel = "shortcuticon" href = "http ://... /Icon. ICO "> "〉
You can. The icon. ICO is a 16x16 icon file. The color must not exceed 16.

39. The separation line of the table can be hidden.
<Table border rules = Cols cellspacing = 0 align = left> horizontal separation lines can be hidden.
<Table border rules = rows cellspacing = 0 align = right> vertical separation lines can be hidden.

<Table border rules = none cellspacing = 0 align = center> horizontal and vertical separation lines can be hidden.

40. The border of the table keeps flashing.

The following method can make the border of the table continue to flash, very practical

Add

<Table border = "0" width = "280" id = "myexample"
Style = "border: 5px solid yellow">

<Tr>

<TD> Add any object. Add any object.

<Br> Add any object. Add any object.

<Br> Add any object. Add any object. </TD>

</Tr>

</Table>

<Script language = "javascript1.2">

<! --

Function flashit (){

If (! Document. All)

Return

If (myexample. style. bordercolor = "yellow ")

Myexample. style. bordercolor = "Lime"

Else

Myexample. style. bordercolor = "yellow"

}

Setinterval ("flashit ()", 500)

// -->

</SCRIPT>

41. Normal table

<Table border = "1" width = "220" style = "position: absolute; left:
11; top: 11 "Height =" 26 ">

Source: (http://blog.sina.com.cn/s/blog_5cd9e1790100bgtv.html)-classic code _ optimal value interconnection _ Sina Blog

<Tr>

<TD width = "100%"> normal table </TD>

</Tr>

</Table>

42. ZhengCubeTable

<Table border = "1" width = "220" bordercolorlight = "# eeeeee"
Bordercolordark = "#000000" style = "position: absolute; left: 10; top:
49 "Height =" 26 ">

<Tr>

<TD width = "100%"> positive cube table </TD>

</Tr>

</Table>

43. Detailed Table

<Table border = "0" frame = vsides width = "219"
Bgcolor = "#000000" cellspacing = "1" cellpadding = "0"
Height = "22" style = "position: absolute; left: 11; top: 86">

<Tr bgcolor = "# ffffff">

<TD width = "100%" Height = "2"> small table </TD>

</Tr>

</Table>

44. three-dimensional table

<Table border = "1" width = "220" bordercolorlight = "# ffffff"
Bordercolordark = "# ffffff" style = "position: absolute; left: 10; top:
112 "Height =" 34 ">

<Tr>

<TD width = "100%" bgcolor = "# b7b7b7"
Bordercolorlight = "#000000" bordercolordark = "# eeeeee"> three-dimensional table </TD>

</Tr>

</Table>

45. Unknown table

<Table width = "220" align = "center" style = "position: absolute;
Left: 246; top: 12 "Height =" 51 ">

<Tr>

<TD> <fieldset style = "width: 220" align = "center">
<Legend> anonymous table </legend> <p align = "right"> </fieldset>
<Br>

</TD>

</Tr>

</Table>

46. Table effect II

<Table width = "220" align = "center" style = "position:
Absolute; left: 245; top: 89 "Height =" 110 ">
<Tr>
<TD Height = "75"> <fieldset style = "width: 220"
Align = "center"> <legend> table effect ⅱ </legend> <Table
Frame = "hsides" border = "1"
Bordercolorlight = "#000000" bordercolordark = "# ffffff"
Width = "100%" cellspacing = "1" cellpadding = "0" Height = "78">
<Tr bgcolor = "# ffffff">
<TD width = "100%" Height = "76"> </fieldset> </TD>
</Tr>
</Table>

47. Table effect I

<Table width = "220" align = "center" style = "position: absolute;
Left: 10; top: 120 "Height =" 138 "cellspacing =" 1"
Cellpadding = "0">

<Tr>

<TD Height = "126"> <fieldset style = "width: 220; color: # b7b7b7;
Border-style: groove "align =" center "> <legend style =" color:
# Ffffff; Border: 1 solid #808080 "> <font color =" #000000 "> table effect I </font>
</Legend> <p align = "right"> </fieldset>

</TD>

</Tr>

</Table>

48. Display borders in the table

Show only the upper border <Table Frame = above>
Show only the lower border <Table Frame = below>
Show only the left and right borders <Table Frame = vsides>
Show only top and bottom borders <Table Frame = hsides>
Show only the left border <Table Frame = LHS>
Show only the right border <Table Frame = RHS>
No border is displayed <Table Frame = void>
</Body>
</Html> </body>
</Html> </body>
</Html>

To create a mobile text file, remove * from the code.

<* I> <* font size = 3 color = Red> <* B> today <*/B> <* font size = 4 color = blue> weather <*/font> <* font size = 5 color = fuchsia> great! <*/Font> <*/I>
The weather is so good today!

The weather is so good today!

<*/Marquee> <* marquee directio = left> La la, I move from right to left! <*/Marquee>

La la, I move from right to left!

<* Marquee direction = right> La la, I move from left to right! <*/Marquee>
La la, I move from left to right!

<* Marquee direction = up> La la, I am moving down and up! <*/Marquee>

La la, I move up from bottom!

<* Marquee direction = down> La la! I moved down from top to bottom! <*/Marquee>

La la, I move down from top to bottom!

# = Scroll, slide, alternate <* marquee behavior = scroll> La la!
La la, I walked around in a circle!

# = Scroll, slide, alternate... I walked around in a circle!
La la, I walked around in a circle!

<* Marquee behavior = slide> La la, I just took a rest! <*/Marquee>

La la! I just took a rest once!

<* Marquee behavior = alternate> La la, let's go back and forth! <*/Marquee>

La la, I'm going back and forth!

<* Loop = #> # = number of times; if not specified, the loop is not limited to (infinite) <* marquee loop = 3 behavior = scroll> La la, I only take 3 trips! <*/Marquee>

# = Number of times; if not specified, more than (infinite) will be loop. I will only take 3 trips!

<* Scrollamount = #> <* marquee scrollamount = 20> change the value of scrollamount = to see my speed change <*/marquee>

Change the value of scrollamount = to see my speed change

Change the value of scrollamount = to see my speed change

<* Scrolldelay = #> <* marquee scrolldelay = 500 scrollamount = 100> I took a step and stopped it! Change the value to see the change <*/marquee>
Let me take a step and stop! Change the value to see the change

Let me take a step and stop! Change the value to see the change

<* Align =#># = Top, middle, and bottom
<* Font size = 6> <* marquee align = # width = 400> La la, I will move it! <*/Font> background color # = rrggbb hexadecimal digital, or predefined color: <* marquee bgcolor = aqua> La la, I will move it! <*/Marquee>

# = Top, middle, bottom
La la, I will move it! Background color # = rrggbb hexadecimal digital, or pre-defined color: la, I will move it!

What is the website ICO icon?
After opening websites such as Microsoft and Baidu, you can see the title bar and address bar of the browser. A small icon is displayed on the labels of multiple browsers. For example, this is what we are talking about here. If a user adds a favorite website, this icon will appear in the user's favorites.

How do I create an ico icon?

Here is the simplest method. Because ICO format pictures are special, general software (such as Windows built-in drawing, Adobe Photoshop, etc.) cannot be made, we will do it in two steps.

The first step is to create an ico source image using a built-in drawing in Windows or Adobe Photoshop. The format can be JPG, JPEG, GIF, or PNG. The size is about 32x32 pixels, preferably 16px × 16px, because the browser title bar and the address bar display this size.

Step 2: Convert the original ICO image to the ICO format. After the image is created, go to a website that can convert the ICO format online (there will be a lot, you can also download a conversion software for processing ). Here we recommend http://www.bitbug.net/, open the site after the interface is very clear, after a few seconds of simple processing can be converted to the ICO format icon file we want, the file is automatically named favicon. ICO.

The ICO icon is created.

How can I display ICO icons on my website?

Insert the following code in the template header (between

<LINK rel = "shortcut icon" href = "/BBS/favicon. ICO">

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.