Summary:In the development of the project, we often encounter pop-up windows, some through the div simulation of the effect of the window, some through the IFRAME, but also through the window's own open function opens a new window. What we're sharing today is the last one to open the page with the window.open () function to interact with the data. First look at the following:
Principle:The parent window passes data to the child window through the parameters of the URL passed in, and the child window passes the data to the parent window through the parent window's global function.
Code:Index.html
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title></Head><Body> <DivID= "Content"></Div> <ButtonID= "Test">Button</Button> <Script> varTest=document.getElementById ('Test'); Test.onclick= function() {window.open ('./window.html?param1=name¶m2=password', '_blank','width=960,height=650,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable= Yes'); }; Window.getcontent= function(TX) {document.getElementById ('content'). InnerText=TX; } </Script></Body></HTML>
Window.html
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title></Head><Body> <DivID= "Content"></Div> <Selectname=""ID= "City"> <optionvalue= "Shanghai">Shanghai</option> <optionvalue= "Hangzhou">Hangzhou</option> </Select> <Script> varparams=location.href.substring (Location.href.lastIndexOf ('?')+1). Split ('&'); document.getElementById ('content'). InnerText=params; var City=document.getElementById (' City'); City.onchange= function() {window.opener.getContent (city.value); } </Script></Body></HTML>
Note: to have a service environment
Other wonderful articles
Android Learning Notes ($) Android Options Menu and submenu (submenu) Android Learning note (notification) features and usage of Android learning Note (Android) using listeners to listen to menu events Android Learning notes (+) Android Create a single-selection menu and a check menuAndroid Learning Notes (Android) setting activity associated with menu itemsAndroid Learning Notes (Android context menu)more about Android Development articles
Passing data between JavaScript browser windows