Home >Web Front-end >JS Tutorial >JS implements getting the value entered in opening an interface_javascript skills
Requirements
Open another interface in one interface and obtain the value entered by the user in the other interface through JS.
Example:
Index.html
聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽
function EntryPoint() {
var style = 'dialogHeight:600px;dialogWidth:800px;status:no;help:0;scroll:yes';
var a = window.showModalDialog('other.html', '', style);
if (a == undefined) {
a = window.returnValue;
聽聽聽聽聽聽聽聽聽聽}
// debugger;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 if (a != null && a.length > 0) {
document.getElementById("name").value = a[0];
document.getElementById("age").value = a[1];
聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
Another interface:
other.html
聽聽聽聽
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽 function postValue() {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 var name = document.getElementById("name").value;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 var age = document.getElementById("age").value;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 var a = new Array();
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 a[0] = name;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 a[1] = age;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 //debugger;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 if (window.opener != undefined) {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 //for chrome
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 window.opener.returnValue = a;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 else {
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 window.returnValue = a;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 window.close();
聽聽聽聽聽聽聽聽聽聽 }
聽聽聽
聽聽聽
聽聽聽
聽聽聽