Simple JavaScript Summary

Source: Internet
Author: User

1. Control the reciprocal of the div tag content from the number 10. The reciprocal interval is 1 second.

    <script tpe="text/javascript">        var g_var = ;        function timerFun() {            if (g_var > 0) {                document.getElementById("count").innerHTML = g_var--;                window.setTimeout(timerFun, 1000);            }            else {                window.close();            }        }        function init() {            window.setTimeout(timerFun, 1000);        }    </script>    <style type="text/css">

2. connect to different pages through input parameters and open different modal windows.

The following is the JavaScript code:

<SCRIPT type = "text/JavaScript"> function opendraw (mode, ID) // input status and award_code {If (mode = 0) {// the URL of award_code Var = "lotterydraw. aspx? Id = "+ ID +" & catch = "+ (new date ()). gettime (); var returnval = Window. showmodaldialog (URL, window, "dialogtop: 0; dialogleft: 0; dialogwidth: 140em; dialogheight: 480em; scrolling: Yes; Status: 0; help: 0 "); if (returnval! = "False") window. Location. Reload ();} else {// award_code var url = "lotteryview. aspx? Id = "+ ID +" & catch = "+ (new date ()). gettime (); window. showmodaldialog (URL, window, "dialogtop: 0; dialogleft: 0; dialogwidth: 640em; dialogheight: 480em; scrolling: Yes; Status: 0; help: 0 ");}} </SCRIPT>

Aspx code:

<Div style = "position: relative; top: 101px; text-align: center; Height: 580px; Background: URL (images/mid_category.gif) No-repeat center; left: -24px; "> <Div class =" menu "> <span>  entire employee work zone </span> <asp: repeater id = "rptcommon" runat = "server" onitemdatabound = "rptcommon_itemdatabound"> 

3. Remove the null characters on both sides of the string to implement the trim function.

// Remove the empty character function trimstr (oobject) {var trimres = nulltrans (oobject); trimres = ltrimstr (trimres); trimres = rtrimstr (trimres ); return trimres;} // determines whether the string is null. If it is null, the function nulltrans (oobject) {var transres = oobject; If (transres = NULL) is returned) {transres = "" ;}return transres;} // remove the left-side empty character function ltrimstr (oobject) {var trimres = nulltrans (oobject); var length = trimres. length; If (length! = 0) {for (I = 0; I <length; I ++) {If (trimres. substr (I, 1 )! = "") {Break ;}} trimres = trimres. substr (I) ;}return trimres;} // remove the empty character function rtrimstr (oobject) {var trimres = nulltrans (oobject); var length = trimres. length; If (length! = 0) {for (I = length-1; I> = 0; I --) {If (trimres. substr (I, 1 )! = "") {Break;} trimres = trimres. substr (0, I + 1);} return trimres ;}

 

Related Article

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.