Words once in school, the front-end of the first course HTML static web design, its teacher, really should his name: Road distance horse horsepower. Throughout the semester, all in Dreamwear drag control to teach, never taught a code. The success of all the students, the class of the nonsense, to drag the control of the experience, think it is ironic, the same time the students are pure handwriting editing interface, we are still immersed in the design of the drag-and-drop operation, bring the interface looks like a thing, but the source is appalling, Later on the internet to watch the Yan 18 teacher's HTML series of video, like winter serve ginseng soup, clairvoyant. So that I did not go farther on the dragging road.
1. Foreground interface intermodulation transfer value, that is, between the sub-interface and the parent interface of those things
① Parent Interface Opener method to get the parent interface element by passing the value to the child interface
<script type="text/javascript"> function Getfather () { var a = Window.opener.document.getElementById ("txt1"). value; var b = window.opener.document.getElementById ("txt2"). Value; Console.log (a); Console.log (b); } </script>
As shown, TXT1, TXT2 is the ID attribute value of two textbox in the parent interface, so that you can directly accept the value, the operation between the pure foreground interface
2. Function execution order, for the General button, you can set the OnClick, OnClientClick, OnCommand events, the execution order is as follows:
①onclientclick invoke JS to set the method
②onclick button Click event to execute after the OnClientClick event
③oncommand is performed in the OnClick event and is typically used in conjunction with the CommandName attribute, which can be tagged when there are most buttons on the interface
3. The foreground method is set to determine whether the OnClick event is executed
<script type="Text/javascript">function Todu () {varTXTBD = document.getElementById ("Txtbd"). Value; if(parseint (TXTBD)! =2) {alert ("to answer the wrong questions and not go into the back."); return false;//Add this } Else{alert ("I'm going to execute the back-table method."); } } </script>
By default, the OnClientClick event executes, is to perform the OnClick event, in the foreground to make a judgment, you need to set two places, one is added in the method, such as comment, and second, in the OnClientClick event, add return False ();
<body> <form id="Form1"runat="Server"> <div> <asp:label id="Lab"runat="Server"></asp:Label> <br/> <asp:textbox id="Txtbd"runat="Server"></asp:TextBox> <asp:button id="btn_to"runat="Server"text="Tobaidu"onclick="Btn_to_click"onclientclick="Todu (); return False ();"/> </div> </form></body>
4. Background call foreground method
① in Page_Load to bind a button to a foreground method (note: The front-end call is slightly different,false is not followed by parentheses )
protected void Page_Load (object sender, EventArgs e) { btn_to. Attributes.Add ("onclick""javascript:return todu (); return false; " ); }
② to bind foreground methods in a button event or method
protected voidBtn_id_click (Objectsender, EventArgs e) { //Add a Script:window.open (' b.aspx ') to the front foot. This. Clientscript.registerstartupscript ( This. GetType (),"","window.open (' b.aspx ')",true); //Add a SCRIPT:ICC () to the front foot; Note: There is no true This. Clientscript.registerstartupscript ( This. GetType (),"","<SCRIPT>ICC ();</script>"); //Add a copy of the Script:alert ("123") to the front foot. Note: single/double quotes Response.Write ("<script type= ' text/javascript ' >alert (' 123 ');</script>"); }
5. Foreground call back-up method
Public int After () { return233; } Public int After2 (intint b) { return a + b; }
For example, in the background there are two methods, one with parameters, one without parameters, then in the foreground method, if the background method is called, as follows:
function Iafter () { var"<%=after ()%>"; alert (b); } function Iafter2 () { var"<%=after2 (5,8)%>" ; Alter (b);
JavaScript interface transfer value and front background intermodulation