JS learning notes

Source: Internet
Author: User

 

Document. lastmodifiedLast modification time of the webpage

Document. Write

Use when outputting"\Escape characters.

Some old browsers cannot browseJavascriptNot deductiveJSOrJSThe function is disabled, orJSWrong.JSIn some cases, the text does not appear on the webpage.JSPut in<! -And//ÀFor example:

<Script language = "JavaScript">

 

 

<! -- To hide the script that cannot work

Document. Write ("nice to meet you all .")

// -->

// This file was created on Jan 2004.

</SCRIPT>

If the function is abnormalHtml.

Window. open ()

Window. Close ()

Window. moveTo ()

Window. moveBy ()

Window. resizeTo ()

Window. resizeBy ()

 

Window. Open

SubwindowProperyCan be setYes(1) OrNo(0):

Menubar = yes/no1/0Whether to use function columns. The default value isNo

ToolbarIndicates whether to use a tool column.No

LocationWhether or not to enter a column in the specified position, default CityNo

Directories = yes/noWhether to preset the connection button column. The default value isNo

Status = yes/noWhether the Status column is required, default CityNo

Scrollbars = yes/noScroll bar required?

ResizableCan I change the window size?

 

Width

Height

<HTML> <body bgcolor = bisque text = red>

 

<SCRIPT>

Adwin = Window. Open ("", "extrawin ",

"Resizable = 1, scrollbars = 1, width = 500, Height = 200 ")

Adwin.doc ument. open ()

Adwin.doc ument. Write ("<HTML> <body bgcolor = beige text = blue> ")

Adwin.doc ument. Write ("<center>

Adwin.doc ument. Write ("

Adwin.doc ument. Write ("Find your computer books here. </font> </B> ")

Adwin.doc ument. Write ("</center> </body>

Adwin.doc ument. Close ()

Document. Write ("test: This shoshould appear in the parent window. <p> ")

</SCRIPT>

<P>

</Body>

 

In the self-window, the parent window's Identification name isOpener. That is, the source window for enabling this sub-Window

<HTML> <body bgcolor = bisque text = red>

<SCRIPT>

Msgwin = Window. Open ("", "win2", "width = 400, Height = 200, menubar = yes ")

With(msgwin.doc ument)

{Open ()

Write ("<HTML> <body> <button ")

Write ("onclick = \ 'your opener.doc ument. bgcolor = \" Yellow \ "\ '> ")

Write ("Change the background color of the parent window</Button> </body>

Close ()

}

</SCRIPT>

<P>

</Body>

MoveTo ()Is to place the upper left corner of the window in the specified position,

MoveByIs to move several points down or to the right at the current position

ResizeTo ()Reset window size

ResizeBy() Increase or decrease

Window. History. Back ()Return

Window. History. Forward ()Forward

Window. Stop ()Stop

Window. scrollto (x, y)Page Jump

Window. scrollby (x, y)

Window. Print ()Print

SetTimeout ()Set a time period

Window. Focus ()Place the cursor on a specified page

Hidden and irrelevant websites

This kind of hidden website is generally used in a main website.Window. open ()To open a ticket.,The purpose is to omit the feature columns of the window.,Fast and easy to collect,For exampleIndex.htmlHas the following program example:

Window. Open ("Hide.htm","Win2",
"Menubar = 0, toolbar = 0, location = 0, directories = 0, status = 0, scrollbars = 0, Height = 0, width = 0 ");

This is to open a new window for loadingHide.htm,Nothing is attached to this new window.,Both height and degree of Parallelism0.

InHide.htmYou can set the following parameters::

<HTML>

<SCRIPT>
Function hideit ()
{Window. resizeTo (0, 0 );
Window. moveTo (2000,2000 );
}
</SCRIPT>
</Head>

<Body onload ="Hideit(); "Onresize ="Hideit(); "Onmove ="Hideit();"
OnUnload = "zookeeper open('hide.htm');">

</Body>

In this case<Body> SetOnload(Opening a window),Onresize(Resize window),Onmobve(Dynamic Location of window Movement)All will be activeFunctionHideit (),InFunctionHideit () The primary actions are the primary key window and2000,2000.

 

What will I do after the website is hidden??The most common thing is time.(For example, every five minutes)An alert is displayed in the response window.,This process is closed,There will be a chapter later saidSetTimeout () OrSetinterval (),Use these twoMethod,You can configure the One-Stop function at a time.

 

Note: When the timer is shut down,The system remembers the size and location of the window when the window is closed.,If the latest connector isHide.htm,When the later timer is enabled, it will be smaller and moved2000,2000Location,If this happens,Is there any simple solution to this problem??Show answer

 

Use the notebook to setHtmCase,Inside<SCRIPT>SetWindow. resizeTo (600,600)AndWindow. moveTo (0, 0),Then the case will be opened in "President of the case ".

 

StatusYesWindowOfPropertyAvailableWindow. Status = "content"In the status bar.

 

If we want the browser to execute our settings, we need to addReturn true

 

WindowOfScreen Object

Screen. Height

Screen. Width

Screen. availheightPixels that can be used by the browser from top to bottom

Screen. availwidthPixels that can be used by the browser from left to right

Screen. colordepthNumber of available colors

Screen. pixeldepth

 

LocationYesWindowOfObjectIndicates the source of the webpage.

LocationTwoMethods: Reload ()(Reload); Replace ()(Replace the current webpage with the specified webpage)

" 2" . Sup ();

Escape ()Is to use this method:Escape (String),String Is the sentence to be written.

Unescape ()Functions and Escape ()Opposite,YesEscape,And returns these characters.,For exampleScript:


Eval ()Is to be processed by the worker,This method is used.:Eval (String),String Is the Representative Text,If the text isExpression,Eval () Will be further checked,IfStatementThis will happen.Statement,For data,Will be calculated.

Please refer to this example:

<HTML> <body>
<SCRIPT>
X=
10
Y=
20
Result= Eval (X>Y)
Alert (Result)
</SCRIPT> </body>

Here Eval (X>Y) Yes X Larger? Y,If,Restore True This word,If not,Restore False This word,So in this example, AlertThe dialog box appears. False This word.

Eval ()The most useful part of this function is that the Force bot processes data as values.,Instead of text. For example, we set a text box to allow readers to write data.,The timer may write dataCompositionWord Processing,If you useEval ()It will be processed by data.

Isnan ()

NanYesNot a numberZookeeper,Isnan () It is used to check whether the data is"Not a number",Use this method:Isnan (Testvalue),ThisTestvalueIs the information to be checked.,If not(Text),Restore True This word,If it is a number,Restore False.

Number ()

This allows you to change an object to a number.,Use this method:Number (OBJ), OBJRepresents an object.,For example Date Put objects Number ()Internal,As follows::

<SCRIPT>
X= New date ("
Dec 25,199 0")
X= Number (X)
Alert (X)
</SCRIPT>

Parseint ()

This isParse INTEGER (Entire Data Extraction),Is the integer that changes a string to a decimal position.,Use this method:Parseint (String, Radix),This Radix Yes String Base number,If this parameter is not specified, it indicates a ten-step path. If Parseint ()Encounter a string that is not a numeric value,Will be restoredNan. If you encounter mixed numbers and letters,It will be extracted to the position before the letter.

Parsefloat ()

This isParse floating number (Extract floating point data),Is the floating point number that starts at the beginning of a string.(Data with small data points)Extracted,Use this method:Parseint (Value),If Parsefloat ()An object is not a numeric value.,Will be restoredNan.

Example1:For example X= Parsefloat (13.12)(X Will wait13.12)

Example2:For example X= Parsefloat ("13.12 version")(X Will wait13.12)

 

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.