The--javascript of ASP.net's close friend

Source: Internet
Author: User
asp.net use asp.net for a long time, found that still can not be separated from JavaScript, whether in the foreground code or backstage, always to the key found JavaScript is indeed a rare good friend, Next to introduce a few in the use of asp.net such as OA or CRM, such as commonly used functions, can also be called Skills bar.

1, the default initialization of the page to maximize the screen

<script language= "JavaScript" >
Self.moveto (0,0);
Self.resizeto (Screen.availwidth,screen.availheight);
Self.focus ();
</script>

2, screen the right mouse button function menu

<script language= "JavaScript" >
if (window. Event)
Document.captureevents (Event.mouseup);

function Nocontextmenu ()
{
Event.cancelbubble = True
Event.returnvalue = false;

return false;
}

function Norightclick (e)
{
if (window. Event)
{
if (E.which = 2 | | e.which = 3)
return false;
}
Else
if (Event.button = 2 | | event.button = 3)
{
Event.cancelbubble = True
Event.returnvalue = false;
return false;
}

}

Document.oncontextmenu = Nocontextmenu; For ie5+
Document.onmousedown = Norightclick; For all others
</script>

3, the display date format is: Wednesday, April 21, 2004 lunar April 23 Lunar New Year March first three

<script language= "JavaScript" >
<!--
var bsyear;
var bsdate;
var Bsweek;
var arrlen=8;
var svalue=0;
var dayiy=0;
var miy=0;
var iyear=0;
var dayim=0;
var spd=86400;

var year1999= "30;29;29;30;29;29;30;29;30;30;30;29"; 354
var year2000= "30;30;29;29;30;29;29;30;29;30;30;29"; 354
var year2001= "30;30;29;30;29;30;29;29;30;29;30;29;30"; 384
var year2002= "30;30;29;30;29;30;29;29;30;29;30;29"; 354
var year2003= "30;30;29;30;30;29;30;29;29;30;29;30"; 355
var year2004= "29;30;29;30;30;29;30;29;30;29;30;29;30"; 384
var year2005= "29;30;29;30;29;30;30;29;30;29;30;29"; 354
var year2006= "30;29;30;29;30;30;29;29;30;30;29;29;30";

var month1999= "first month; February; March; April; May; June; July; August; September; October; November; December"
var month2001= "first month; February; March; April; April; May; June; July; August, September;
var month2004= "First month, February, February, March, April, May, June, July, August, September"
var month2006= "First month, February; March; April; May; June; July; July; August; September;
var dn= "; The Hansi of the Duanwu; arrest; when初七because; day; Yanji; 11; 15; 16; 17 18; 19; 20; 14 21; 12; 22; 23.24; 25; 26; 13

var ys=new Array (Arrlen);
ys[0]=919094400; ys[1]=949680000; ys[2]=980265600;
ys[3]=1013443200; ys[4]=1044028800; ys[5]=1074700800;
ys[6]=1107878400; ys[7]=1138464000;

var yn=new Array (Arrlen); The name of the lunar year
Yn[0]= "The years of their own;" Yn[1]= "The Year of Geng Chen"; Yn[2]= "Singonan";
Yn[3]= "The year of the Siren"; yn[4]= "Year"; Yn[5]= "Jia Shen Year";
Yn[6]= "B unitary year"; Yn[7]= "The Year of the" C Xu;

var d=new Date ();
var yy=d.getyear ();
var mm=d.getmonth () +1;
var dd=d.getdate ();
var ww=d.getday ();

var ss=parseint (D.gettime ()/1000);
if (yy<100) yy= "+yy";

for (i=0;i<arrlen;i++)
if (Ss>=ys[i]) {
Iyear=i;
Svalue=ss-ys[i]; The number of seconds in the year
}
Dayiy=parseint (SVALUE/SPD) +1; Days of the Year

var dpm=year1999;
if (iyear==1) dpm=year2000;
if (iyear==2) dpm=year2001;
if (iyear==3) dpm=year2002;
if (iyear==4) dpm=year2003;
if (iyear==5) dpm=year2004;
if (iyear==6) dpm=year2005;
if (iyear==7) dpm=year2006;
Dpm=dpm.split (";");

var mn=month1999;
if (iyear==2) mn=month2001;
if (iyear==5) mn=month2004;
if (iyear==7) mn=month2006;
Mn=mn.split (";");

var dn= "; The Hansi of the Duanwu; arrest; when初七because; day; Yanji; 11; 15; 16; 17 18; 19; 20; 14 21; 12; 22; 23.24; 25; 26; 13
Dn=dn.split (";");

Dayim=dayiy;
var total=new Array (13);
Total[0]=parseint (Dpm[0]);
for (i=1;i<dpm.length-1;i++) Total[i]=parseint (Dpm[i]) +total[i-1];
for (i=dpm.length-1;i>0;i--)
if (Dayim>total[i-1]) {
DAYIM=DAYIM-TOTAL[I-1];
Miy=i;
}

BSYEAR2=MN[MIY]+DN[DAYIM-1];
if (ss>=ys[7]| | Ss<ys[0]) bsyear=yn[7];
document.write ("lunar" +bsyear2);
-->
</script>

4. Randomly select landing page

<script language= "JavaScript" >>
var url=new Array ("index1.htm", "index2.htm", "index3.htm", "index4.htm", "index5.htm")
Pnum=math.floor (Math.random () *5)
Location.href=url[pnum]
</script>

5, the page cannot use the copy and the shearing function (prevents the mouse to choose)

Change the body to: < body onmousemove= "EVENT.RETURNVALUE=FALSE;" >

6, get the key KeyCode code

Change the body to: <body Onkeydown=alert (Event.keycode) >



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.