Javascript is a good scripting language for Dynamic Interaction. Below are common JavaScript techniques I have summarized.
(1). Reference in the HTML page:
<Script language = "JavaScript">... </SCRIPT> // method 1
<Script language = "JavaScript" src = "JS file path (usually relative path)"/>
(2) Add to favorites: <a href = "javascript: window. external. addFavorite (location. href, document. title) "> Add to favorites </a> where location. href indicates the current page, document. title refers to the text displayed to the user (for convenience of memory) when added to the favorites.
(3) On the Asp.net server side, click OK and return to the previous page: reponse. write ("<SCRIPT> alert ('xxx'); history. go (-1); </SCRIPT> ");
(4) Save the page as: <a href = "#" onclick = "document.exe ccommand ('saveas')"> save it as </a>
(5) Click "enter" on the page, which is equivalent to triggering a button:
Function document. onkeydown ()
{
If (event. keycode = 13) // note the case sensitivity and determine whether to press Enter.
{
Document. getelementbyid ("btnok"). Click (); // btnok is the server-side control
Return false; // be sure to have
}
}
/* If the text box for receiving passwords is a client control, you can also define it as follows, and then do the following:
// Call <input id = "PWD" onkeydown = "enterdown (Button Object Name)"/>
Function enterdown (OBJ)
{
If (event. keycode = 13)
{
OBJ. Click ();
}
}
*/
(6) A new window is displayed: <a href = "#" onclick = "window. open ('keeppasswordonpageaftersubmit. aspx ',' _ blank ', 'height = 500, width = 100, toolbar = No, menubar = No, location = no') "> open </a>
(7) When deletion or closure is enabled, a prompt dialog box is displayed: <input id = "button3" type = "button" value = "button" onclick = "javascript: if (confirm ('do you want to close? ') Window. Close (); "/> </div>