Methods of Javascript:window objects

Source: Internet
Author: User
Tags eval expression window
javascript|window| objects

Open (url,windowname,parameterlist): The Open method creates a new browser window and loads a specified URL address in a new window.
Close (): Closing method closes a browser window.
Alert (text): POPs up an information box.
Confirm (text): POPs up a confirmation box.
Prompt (Text,defaulttext): pops up a prompt box.
SetTimeout (expression,time): Timed settings, automatically after a certain period of time to execute the expression description of the code, use time to set the times, in milliseconds.
Cleartimeout (timer): Cancels the previous timer setting.
Back (): Instructs the browser to load the previous URL address in the history.
Forward (): Instructs the browser to load the next URL address in the history.
Stop (): Instructs the browser to stop loading the Web page.
Location: Provides URL information for the current window
History: Provides the history of the current window, and can play a role in Web navigation.
Closed: A logical value that indicates whether the window is currently closed.
Self: Refers to the window corresponding to the current document.
Prompt box, confirmation box, the use of the input box:
Tip box: Use the alert (text) method to create, display a short message, only one OK button.
Example: Alert ("Your input is hello!");
Confirmation Box: Use the Confirm (text) method to create, display a short message with OK and Cancel buttons.
Example: Confirm ("confirm?");
Input box: Create with Prompt (Text,defaulttext), display a piece of information, the user can enter a text input box in a certain text.
Example: Prompt ("Please enter your name:", "");


<script language= "JavaScript" >
<!--
function Suredo (SRC,Q)
{
VAR ret;
ret = confirm (q);
if (ret!=false) window.location=src;
}
-->
</script>

<a href= ' Javascript:suredo ("http://www.cnbruce.com/bluebook/", "Are you sure you want to go?") ' >my flashbook</a>

You can confirm the query before deleting the recordset.

Another example is the code for the automatic jump menu generated by DW, which defaults to the open in this window


<script language= "JavaScript" type= "Text/javascript" >
<!--
function Mm_jumpmenu (targ,selobj,restore) {//v3.0
Eval (targ+ "location=" "+selobj.options[selobj.selectedindex].value+");
if (restore) selobj.selectedindex=0;
}
-->
</script>

<select name= "Menu1" >
<option value= "Http://www.blueidea.com/bbs" selected> Classic Forum </option>
<option value= "Http://www.blueidea.com/bbs" > Classic Forum </option>
<option value= "Http://www.blueidea.com/bbs" > Classic Forum </option>
</select>


Note: DW automatically generates targ+ ". location= '" When the argument is applied parent.location only the current window opens.
The new open window required is the Window.Open method. Therefore, in the original DW code based on the modification of JS.

Eval (targ+ "location=" "+selobj.options[selobj.selectedindex].value+");
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

Eval (targ+. Open (' "+selobj.options[selobj.selectedindex].value+") ");

Parameter calls

Mm_jumpmenu (' parent ', this,0)
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

Mm_jumpmenu (' window ', this,0) "

<script language= "JavaScript" type= "Text/javascript" >
<!--
function Mm_jumpmenu (targ,selobj,restore) {//v3.0
Eval (targ+. Open (' "+selobj.options[selobj.selectedindex].value+") ");
if (restore) selobj.selectedindex=0;
}
-->
</script>

<select name= "Menu1" >
<option value= "Http://www.blueidea.com/bbs" selected> Classic Forum </option>
<option value= "Http://www.blueidea.com/bbs" > Classic Forum </option>
<option value= "Http://www.blueidea.com/bbs" > Classic Forum </option>
</select>


Of course, the usual use of this is this.


<select >
<option selected> More Links ......</option>
<option value= "http://www.cnbruce.com" >cnbruce</option>
<option value= "http://daonet.myrice.com/old/" >daonet</option>
<option value= "http://www.blueidea.com" >blue!dea</option>
</select>



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.