Recent collection of useful javscript tips

Source: Internet
Author: User
Skills

<input style= "ime-mode:disabled" > Close IME

Cursor is stopped at the end of text box text
<script language= "JavaScript" >
function cc ()
{
var e = event.srcelement;
var r =e.createtextrange ();
R.movestart (' character ', e.value.length);
R.collapse (TRUE);
R.select ();
}
</script>
<input type=text name=text1 value= "123" >

Keep pop-up windows always on top:
<body onblur= "This.focus ();" >

How to remove the picture link after clicking the dotted line around the picture?
<a href= "#" ></a>

How do I write in the code that refreshes the parent window in the Open child window?
Window.opener.location.reload ()

How to set the size of an open page
<body >
The location where the page opens <body >

How to add a background picture that is not a full spread in the page, the background image does not move when pulling the page
<STYLE>
Body
{Background-image:url (logo.gif); background-repeat:no-repeat;

Background-position:center;background-attachment:fixed}
</STYLE>

Check whether a string of strings is composed entirely of digits
<script language= "Javascript" ><!--
function Checknum (str) {return Str.match (//d/) ==null}
Alert (Checknum ("1232142141"))
Alert (Checknum ("123214214A1"))
--></script>

Get the size of a window
Document.body.clientWidth; Document.body.clientHeight

How to judge whether it is a character
if (/[^/x00-/xff]/g.test (s)) alert ("contains Chinese characters");
else alert ("All characters");

TextArea the number of adaptive lines of text
<textarea Rows=1 name=s1 cols=27 onpropertychange= "This.style.posheight=this.scrollheight" >
</textarea>

Date minus days equals second date
<script language=javascript>
function cc (DD,DADD)
{
You can add error handling
var a = new Date (DD)
A = A.valueof ()
A = A-dadd * 24 * 60 * 60 * 1000
A = new Date (a)
Alert (a.getfullyear () + "year" + (A.getmonth () + 1) + "month" + a.getdate () + "Day")
}
CC ("12/23/2002", 2)
</script>

No Close button IE
window.open ("aa.htm", "Meizz", "fullscreen=7");

Window maximization
<body >



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.