8 JavaScript small special effect Codes

Source: Internet
Author: User

1. display different greetings in different time periods

<Script Language = "Javascript"> <"〉〈! -- Var text = ""; day = new Date (); time = day. getHours (); if (time> = 0) & (time <7) text = "night owl, pay attention to your health! "If (time> = 7) & (time <12) text =" Today's sunshine is so bright, what about your friend? "If (time> = 12) & (time <14) text =" lunch break time. You need to stay asleep! "If (time> = 14) & (time <18) text =" Have a good afternoon! "If (time >= 18) & (time <= 22) text =" You're coming again. Don't talk to MM too long! "If (time> = 22) & (time <24) text =" you should have taken a rest! "Document. write (text) // ---> </script> 〉

2. The window that grows slowly

<Script Language = "Javascript"> <"〉〈! -- Var Windowsheight = 100 var Windowswidth = 100 var numx = 5 function openwindow (thelocation) {temploc = thelocation if (! (Window. resizeTo & document. all )&&! (Window. resizeTo & document. getElementById) {window. open (thelocation) return} windowsize = window. open ("", "", "scrollbars") windowsize. moveTo (0, 0) windowsize. resizeTo (100,100) tenumxt ()} function tenumxt () {if (Windowsheight >= screen. availHeight-3) numx = 0 windowsize. resizeBy (5, numx) Windowsheight + = 5 Windowswidth + = 5 if (Windowswidth >= screen. width-5) {windowsize. location = temploc Windowsheight = 100 Windowswidth = 100 numx = 5 return} setTimeout ("tenumxt ()", 50 )} // --> </script> <p> <a href = "javascript: openwindow ('HTTP: // www.ccjol.com ')"> enter </a> 〉

3. Change the IE icon in the IE Address Bar

We need to first create a 16*16 icon (icon file) and save it as index. ico. Upload the Icon file to the root directory and add the following code between the home page
4. Move the webpage back at will

<A href = "javascript: history. go (-X) "> X </a> // change X to the number of pages you want to move back. // change"-"to" + "to forward.

5. A dialog box pops up when the cursor points

Add the following code between <body> </body>: <a href onmouseover = "alert ('pop-up message! ') "> Displayed link text </a> 〉

6. Right-click to bring up the Add favorites dialog box.

Add the following code between <body> </body>: <script Language = Javascript> if (document. all) document. body. onmousedown = new Function ("if (event. button = 2 | event. button = 3) window. external. addFavorite ('your website', 'Your website name) ") </script> 〉

7. Random conversion of background images (a special effect that refreshes the mood)

Add the following code between
8. translucent display of the table

<Head> <style> 〉. alpha {filter: Alpha (Opacity = 50 )} // 50 indicates the transparency of 50% </style>

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.