JS 는 하나의 인터페이스 에서 입력 한 값 을 가 져 옵 니 다.
11641 단어 js
한 화면 에서 다른 화면 을 열 고 JS 를 통 해 다른 화면 에서 사용자 가 입력 한 값 을 가 져 옵 니 다.
예시:
Index.html
1: <html> 2: <head> 3: <meta http-equiv="content-type" content="text/html; charset=gbk"> 4: <title> </title> 5: <script type="text/javascript"> 6: function EntryPoint() { 7: var style = 'dialogHeight:600px;dialogWidth:800px;status:no;help:0;scrool:yes'; 8: var a = window.showModalDialog('other.html', '', style); 9: 10: if (a == undefined) { 11: a = window.returnValue; 12: } 13: // debugger; 14: if (a != null && a.length > 0) { 15: document.getElementById("name").value = a[0]; 16: document.getElementById("age").value = a[1]; 17: } 18: } 19: </script> 20: </head> 21: <body> 22: <input type="button" value=" " onclick="EntryPoint()"/><br/> 23: <input type="text" name="name" id="name" /><br/> 24: <input type="text" name="age" id="age" /> 25: </body> 26: </html> .csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
다른 인터페이스:
other.html
1: <html> 2: <head> 3: <title> </title> 4: 5: <meta http-equiv="content-type" content="text/html; charset=gbk"> 6: 7: <script type="text/javascript"> 8: function postValue() { 9: var name = document.getElementById("name").value; 10: var age = document.getElementById("age").value; 11: var a = new Array(); 12: a[0] = name; 13: a[1] = age; 14: //debugger; 15: if (window.opener != undefined) { 16: //for chrome 17: window.opener.returnValue = a; 18: } 19: else { 20: window.returnValue = a; 21: } 22: window.close(); 23: } 24: </script> 25: </head> 26: <body> 27: <input type="button" value=" " onclick="postValue();"/><br/> 28: :<input type="text" name="name" id="name" /><br/> 29: :<input type="text" name="age" id="age" /> 30: </body> 31: </html> .csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
이 DEMO 에서 문제 가 발생 했 습 니 다. 바로 chrome 에서 window. close () 방법 이 작 동 하지 않 는 다 는 것 입 니 다.마지막 으로 window. opener 를 통 해 chrome 과 IE 의 충돌 을 해결 합 니 다.
구체 적 인 참고:
http://www.cnblogs.com/chopper/archive/2012/06/25/2556266.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[2022.04.19] 자바스크립트 this - 생성자 함수와 이벤트리스너에서의 this18일에 this에 대해 공부하면서 적었던 일반적인 함수나 객체에서의 this가 아닌 오늘은 이벤트리스너와 생성자 함수 안에서의 this를 살펴보기로 했다. new 키워드를 붙여 함수를 생성자로 사용할 때 this는...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.