Home >Web Front-end >JS Tutorial >JS implements getting the value entered in opening an interface_javascript skills

JS implements getting the value entered in opening an interface_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:40:061171browse

Requirements
Open another interface in one interface and obtain the value entered by the user in the other interface through JS.
Example:
Index.html

Copy code The code is as follows:

聽聽聽聽聽聽聽聽聽聽

Homepage

聽聽聽聽聽聽聽聽聽聽

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

Copy code The code is as follows:

聽聽聽聽

聽聽聽聽聽聽聽聽

鎿嶄綔鐣岄潰

聽聽聽聽聽聽聽聽聽

聽聽聽聽聽聽聽聽

聽聽聽聽聽聽聽聽聽

聽聽聽聽聽聽聽

聽聽聽聽聽聽聽聽聽聽聽 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();

聽聽聽聽聽聽聽聽聽聽 }

聽聽聽

聽聽聽

聽聽聽

聽聽聽

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn