a.html
=========================================
<html>
<head>
<script>
window.onload=function(){
b.onclick=function(){
newWin=window.open("bb.html","nw","");
}
}
</script>
</head>
<body>
<input type="text" id="t">
<input type="button" id="b" value="주소검색">
</body>
</html>
bb.html
===================================================
<html>
<head>
<script>
window.onload=function(){
var array=["진주시","창원시","마산시"];
var buffer=[];
for(var i=0; i<3; i++){
buffer.push("<a href=# onclick=sel('"+array[i]+"')>"+array[i]+"</a><br>");
}
con.innerHTML=buffer.join("");
b.onclick=function(){
window.opener.document.getElementById("t").value=t.value;
}
}
function sel(v){
t.value=v;
}
</script>
</head>
<body>
<div id="con"></div>
<input type="text" id="t">
<input type="button" id="b" value="확인">
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
document 객체 (0) | 2015.02.26 |
---|---|
select 한 option 값을 이용해서 배경색바꾸기 onchange사용의 예 (0) | 2015.02.26 |
text value값을 id로 이용하기 eval,getElementById (0) | 2015.02.26 |
window.open(새창띄우기) (0) | 2015.02.26 |
onfocus,onblur (0) | 2015.02.26 |