Common JS webpage code

Source: Internet
Author: User

Common JS webpage code
 
1. Move backward
<Input type = "button" value = "back" onclick = "history. Go (-1)">
<Input type = "button" value = "Forward" onclick = "history. Go (1); Return true;">

2. Return
<Form> <input type = "button" value = "back to previous step" onclick = "history. Back (-1)"> </form>

3. View Source Code
<Input type = "button" name = "View" value = "view source code" onclick = "window. Location =" view-source: "+ window. Location. href">

4. Do not view source code
<Body oncontextmenu = "Return false"> </body>

5. Refresh button 1
<Input type = "button" value = "Refresh button 1" onclick = "reloadbutton ()">
<SCRIPT> function reloadbutton () {location. href = "i001.htm" ;}</SCRIPT>

Refresh button 2
<Input type = "button" value = "Refresh button 2" onclick = "history. Go (0)">

6. Home page buttons
<Input type = "button" value = "Homepage" onclick = "homebutton ()">
<SCRIPT> function homebutton () {location. href = http://www.winliuxq.com;} </SCRIPT>

7. A warning box is displayed.
<Input type = "button" value = "pop-up warning box" onclick = "alertbutton ()">
<SCRIPT> function alertbutton () {window. Alert ("coming soon! ") ;}</SCRIPT>

8. Status Bar Information
<Input type = "button" value = "status bar information" onclick = "statusbutton ()">
<SCRIPT> function statusbutton () {window. Status = "coming soon! ";}</SCRIPT>

9. Background Color Conversion
<Form> <input type = "button" value = "background color conversion" onclick = "bgbutton ()"> </form>
<SCRIPT> function bgbutton (){
If (document. bgcolor = '# 00ffff ')
{Document. bgcolor = '# ffff ';}
Else {document. bgcolor = '# 00ffff ';}
}
</SCRIPT>

10. open a new window
<Input type = "button" value = "open a new window" onclick = "newwindow ()">
<SCRIPT> function newwindow () {window. open ("c01.htm", "", "Height = 240, width = 340, status = No, location = No, toolbar = No, directories = No, menubar = No ");}
</SCRIPT>

11. Minimize windows
<Object ID = "min" type = "application/X-oleobject" classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11 "> <Param name =" command "value =" minimize "> </Object> <button onclick =" Min. click () "> minimize the window </button>

12. Full Screen code
<Input type = "button" name = "fullscreen" value = "full screen" onclick = "window. open (document. location, 'butong _ net', 'fullscreen ') ">

13. Close the window
<Object ID = closes type = "application/X-oleobject" classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11 "> <Param name =" command "value =" close "> </Object> <input type =" button "value =" Close Window "onclick =" closes. click (); ">

Close Window
<Input type = button value = Close Window onclick = "javascript: Self. Close ()">

14. Maximize
<Object ID = big classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "maximize"> </Object> <input type = button value = maximized onclick = big. Click ()>

15. Disable the Input Method
<Input style = "ime-mode: Disabled" value = Disable the input method>

16. link button 1
<Input type = "button" value = "link button 1" onclick = "window. open ('HTTP: // www.winliuxq.com/', 'sample', 'toolbar = No, location = No, directories = No, status = No, menubar = No, scrollbars = No, resizable = Yes, copyhistory = Yes, width = 790, Height = 520, Left = 0, Top = 0') "name =" input ">

Link button 2
<Input type = "button" name = "button" value = "link button 2" onclick = "showmodaldialog ('HTTP: // www.winliuxq.com/')">

Link button 3
<Input type = "Submit" value = "link button 3" onclick = "location. href = 'HTTP: // www.winliuxq.com/'">

17. The source code is displayed in the warning box.
<Button onclickpolicalert(document.doc umentelement. outerhtml) style = "width: 110"> the source code is displayed in the warning box. </button>

18. Click "clear ".
<Input type = button value = 'output' onclick = "This. style. Visibility = 'ddd'; window. Print ();">

19. Print
<Input type = button value = 'print 'onclick = "window. Print ();">

20. Print and preview
<Object classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2" Height = 0 id = WB name = WB width = 0> </Object>
<Input type = button value = print preview onclick = "wb.exe CWB (7,1)">

21. Save
<Input onclick = "document.execcommand('saveas', 'true', 'common code .htm')" type = button value = Save As>

22. Click auto copy.
<SCRIPT> function ocopy(objpolic{obj.select(;;js=obj.createtextrange(;;;js.exe ccommand ("copy")} </SCRIPT>
<Input type = "text" value = "Click auto copy" onclick = "ocopy (this)" size = "11">

23. Automatically Selected
<Input value = "automatically select" onfocus = "This. Select ()" onmouseover = "This. Focus ()" size = "11">

24. Open source code
<Button onclick = "document. Location = 'view-Source: '+ document. Location" size = "7"> open source code </button>

25. delayed opening of new windows
<Input type = button value = new window delayed onclick = javascript: setTimeout ("window. Open ('HTTP: // www.winliuxq.com/')", 10000)>

26. Implement the First Half of the selected text box
<Input type = "text" value = "select the first half of the content in the text box" size = 30 onmouseover = "this. select (); Tr = document. selection. createRange (); tr. moveend ('character ',-8); tr. select (); ">
<Input type = "text" value = "selected content. For non-ie, you can use this" size = 30 onmouseover = "this. selectionstart = This. value. length-4; this. selectionend = This. value. length ">

27. Click "clear text ".
<Input type = "text" name = "artist" size = 14 value = "click to clear text" onmouseover = This. focus () onfocus = This. select () onclick = "If (this. value = 'click to clear text') This. value = ''">

Click Clear Text
<Input name = Name size = 11 value = click to clear the text onmouseover = This. focus () onblur = "If (this. value = '') This. value = 'click to clear text' "onfocus = This. select () onclick = "If (this. value = 'click to clear text') This. value = ''">

28. Title ):
<Input type = "text" value = "" id = "AA" size = "20">
<SCRIPT> document. getelementbyid ("AA"). value = Document. Title; </SCRIPT>

29. Check whether IE is offline
<Input type = "button" value = "test" onclick = "alert (window. Navigator. Online)">

30. 11 refresh button Methods
<Input type = button value = Refresh onclick = "history. Go (0)">
<Input type = button value = Refresh onclick = "location. Reload ()">
<Input type = button value = Refresh onclick = "location = location">
<Input type = button value = Refresh onclick = "location. Assign (location)">
<Input type = button value = Refresh onclick = "document.exe ccommand ('refresh')">
<Input type = button value = Refresh onclick = "window. navigate (location)">
<Input type = button value = Refresh onclick = "location. Replace (location)">
<Input type = button value = Refresh onclick = "window. Open ('own files', '_ Self')">
<Input type = button value = Refresh onclick = Document. All. webbrowser. execwb (22, 1)>
<Object classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2 Height = 0 id = webbrowser width = 0> </Object>
<Form action = "your files"> <input type = submit value = Refresh> </form>
<A id = A1 href = "your files"> </a> <input type = button value = Refresh onclick = "a1.click ()">

31,

<A href = "#" onclickappsdocument.exe ccommand ("open")> open </a>

32,

<A onclick = "too many open('i001.htm','', 'height = 300, width = 300, resizable = No, location = net '); "href =" "> open a webpage of the specified size </a>

33,

<A href = "#" onclick = location. Replace ("view-source:" + location)> edit with notepad </a>

34,

<A href = "#" onclickappsdocument.exe ccommand ("saveas")> Save As </a>

35,

<A href = "#" onclickappsdocument.exe ccommand ("print")> Print </a>

<A href = "javascript: window. Print ();"> Print </a>

36,

<A href = mailto: 429752806@163.com> send e-mail </a>

37,

<A href = "#" onclickappsdocument.exe ccommand ("selectall")> select all </a>

38,

<A href = "#" onclick = location. Reload ()> refresh 1 </a>

39,

<A href = "#" onclick = history. Go (0)> refresh 2 </a>

40,

<A href = "#" onclick = location. Replace ("view-source:" + location)> View source files </a>

41,

<A href = "#" onclick = Window. Open (document. Location, "url", "fullscreen")> full screen display </a>

42,

<A href = "#" onclick = Window. External. showbrowserui ("privacysettings", null)> Internet Options </a>

43,

<A href = "#" oncontextmenu = "window. Open (this. href); Return false;"> right-click to open in a new window </a>

44,

<A href = "#" onclick = history. Go (1)> forward 1 </a>

<A href = "#" onclick = history. Forward ()> forward 2 </a>

<A href = "#" onclick = history. Go (-1)> 1 </a>

<A href = "#" onclick = history. Back ()> 2 </a>

45,

<A href = "#" onclick = Window. External. showbrowserui ("organizefavorites", null)> sort favorites </a>

<Span onclick = "window. External. AddFavorite ('HTTP: // www.winliuxq.com/', 'webpage special site point')" style = "cursor: Hand" Title = webpage special effect site> Add to favorites </span>

<A href = "#" onclick = "window. External. AddFavorite ('HTTP: // www.winliuxq.com/', 'webpage special site point')"> Add to favorites </a>

<A href = "javascript: window. External. AddFavorite ('HTTP: // www.winliuxq.com/', 'webpage special effect site')"> click to add to favorites </a>

<A href = "#" onmouseover = "window. External. AddFavorite ('HTTP: // www.winliuxq.com/', 'webpage special site point')" target = "_ Self"> mouse sensing site </a>

<A href = "#" onmouseover = "this. style. behavior = 'url (# default # homepage) '; this. setHomePage ('HTTP: // www.yiloo.com/js/'); "target =" _ Self "> set the mouse to the home page </a>

46,
<A href = "javascript: window. Close ()"> close the window </a>

<A href = "#" onclick = Window. Close (); Return false)> close the window </a>

<A href = "#" onclick = setTimeout (window. Close (), 3000)> close this window in 3 seconds </a>

<SCRIPT>
Function shutwin (){
Window. Close ();
Return ;}
</SCRIPT>
<A href = "javascript: shutwin ();"> close this window </a>

47. <span onclick = "Var strhref = Window. location. href; this. style. behavior = 'url (# default # homepage) '; this. setHomePage ('HTTP: // www.winliuxq.com/'); "style =" cursor: Hand "> set as homepage </span>

48. equal to the title bar: <SCRIPT> document. Write (document. Title); </SCRIPT>

49,
<A href = "javascript: void (0);" onclick = 'window. External. AddFavorite (location. href, document. Title); '> Add this page to favorites </a>

<A href = "javascript: window. External. AddFavorite (document. Location. href, document. Title)"> Add this page to favorites </a>

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

50,
<A href = "i003.htm" onclick = "Return false;" ondblclick = "too many open('i003.htm');"> double-click to open the link </a>

51,
<Style> # Close A: hover {Background: URL (javascript: window. opener = 0; window. close () ;}</style> <Div id = close> <a href = ""> close the window </a> </div>

52,
<A href = "javascript: void (0)" onmouseover = "alert ('Sorry, do not select! ') "> The link is not allowed </a>

 

<Body style = "filter: alpha (opacity = 50)">

55. Select the background color randomly.
<Body>
<SCRIPT>
Document. body. style. background = (["red", "blue", "pink", "Navy", "gray", "yellow", "green", "Purple"]) [parseint (math. random () * 8)];
</SCRIPT>

56. The scroll bar is not displayed on the frame page:
<SCRIPT>
Self. moveTo (0, 0)
Self. resizeTo (screen. availwidth, screen. availheight)
</SCRIPT>

57. Prevent webpage Frame
<Script language = JavaScript>
If (top. location! = Self. Location ){
Top. Location = self. location;
}
</SCRIPT>

58. Always carry the framework
<Script language = "JavaScript"> <! --
If (window = Top) top. Location. href = "frame.htm"; // framework webpage
// --> </SCRIPT>

59. Automatic window Maximization
<Script language = "JavaScript"> <! --
Self. moveTo (0, 0)
Self. resizeTo (screen. availwidth, screen. availheight)
// --> </SCRIPT>

60. automatically maximize window opening
<Object classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange = "If (this. readystate = 4) This. click (); "viewastext> <Param name =" command "value =" maximize "> </Object>

61. eye-catching pop-up code
<SCRIPT> var color = new array; color [1] = "black"; color [2] = "white"; for (x = 0; x <3; X ++) {document. bgcolor = color [X]; If (x = 2) {x = 0 ;}</SCRIPT>

62. cannot be saved
<NoScript> <IFRAME src = *. html> </iframe> </NoScript>

63. Call the Chinese Character Library
<SCRIPT>
For (I = 19968; I <40870; I ++) document. Write (string. fromcharcode (I ));
</SCRIPT>

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

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

66. Press the F12 key and return directly to the Home Page
<SCRIPT> function look (){
If (event. keycode = 123) {document. Location. href = http://www.winliuxq.com /}
}
If (document. onkeydown = NULL)
{Document. onkeydown = Look}
</SCRIPT>

67. Port Detection

 

68. Windows that cannot be minimized
<Body onblur = 'self. Focus (); '>

69. Link point external CSS file
<Style> @ import URL ("ie.css"); </style>

70. Embedded framework-call another webpage on a webpage:
<Object type = "text/X-scriptlet" width = "600" Height = "1000" Data = "http://www.winliuxq.com/"> </Object>

71. Refresh and change the window size
<Object classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11" onreadystatechange = "If (this. readystate = 4) This. click (); "viewastext> <Param name =" command "value =" maximize "> </Object>

72. Javascript implements vertical dotted lines on webpages
<SCRIPT> Hei = 120; D1 = 2; d2 = 2; cou = math. Floor (HEI/(d1 + D2 ));
Document. Write ('<Table cellspacing = 0 cellpadding = 0 width = 1 Height =' + Hei + '> ');
For (I = 0; I <cou; I ++) {document. write ('<tr> <TD Height =' + D2 + '> <tr> <TD Height =' + D1 + 'bgcolor = 333333> ')} </SCRIPT> </table>

73. js Paging
<SCRIPT> document. write ("<a href =" + location. href. replace (//. html/g, "_2.html") + "> 2 </a>"); </SCRIPT>
 

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.