본문 바로가기
개발/html,Thymeleaf

iframe으로 만들기

by 카앙구운 2015. 8. 4.
728x90
반응형

 

잘쓰진 않지만 iframe을 이용해서 만들어봄

iframeTestMain.html

중요부분 빨간색 표시

---------------------------------------------------------------------s
 <head>
  <meta charset="UTF-8">
  <title>Document</title>
 </head>
 <script>
function fn_sub1(a){
 if(a=="m"){
  ifmSrc.location.href="iframeTestSub1.php";
 }else if(a=='t'){
  ifmSrc.location.href="iframeTestSub2.php";
 }
}
 </script>
 <body>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#ccccccc">
 <form name="frm">
 <tr>
  <td bgcolor="#ffffff">
  <input type="button" value="모니터" onClick="fn_sub1('m')">
  <input type="button" value="TV" onClick="fn_sub1('t')">
  </td>
 </tr>
 <tr>
  <td bgcolor="#ffffff">
  <iframe id="ifmSrc" src="" border="1" width="300" height="300"></iframe></td>
 </tr>
 <tr>
  <td bgcolor="#ffffff"><input type="text" name="moniterV"></td>
 </tr>
 <tr>
  <td bgcolor="#ffffff"><input type="text" name="tvV"></td>
 </tr>
 </form>
</table>
 </body>
</html>

----------------------------------------------------------------------e

iframeTestSub1.php

----------------------------------------------------------------------s

<meta charset="utf-8">
<?
$moniter=Array("samsung17","samsung18","samsung19","samsung20");
$mCnt=count($moniter);
?>

<script>
function fn_a(){
 var f=eval(document.frm);
 var mt=f.moniter.value;
 var msg="모니터:"+mt;

 parent.frm.moniterV.value=msg; //새창의 경우 parent 대신 opener사용
 
}
</script>
<html>
<body>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#ccccccc" width="200" height="100">
 <form name="frm">
 <tr>

  <td bgcolor="#ffffff">모니터:
  <select name="moniter">
  <?
  for($i=0;$i<$mCnt;$i++){
  ?>
  <option value="<?=$moniter[$i]?>"><?=$moniter[$i]?></option>
  <?}?>
  </select>
  </td>
 </tr>
 <br>
 <tr>
  <td bgcolor="#ffffff" align="center"><input type="button" value="적용" onClick="fn_a()"></td>
 </td>
 </form>
</table>
</body>
</html>

----------------------------------------------------------------------e

iframeTestSub2.php

----------------------------------------------------------------------s


<meta charset="utf-8">
<?
$tv=Array("samsung50","samsung55","samsung60","samsung30");
$tCnt=count($tv);
?>

<script>
function fn_b(){
 var f=eval(document.frm);
 var tv=f.tv.value;
 var msg="Tv : "+tv;

 parent.frm.tvV.value=msg;

}
</script>
<html>
<body>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#ccccccc" width="200" height="100">
 <form name="frm">
 <tr>
  <td bgcolor="#ffffff" align="center">Tv:

<select name="tv">
  <?
  for($i=0;$i<$tCnt;$i++){
  ?>
  <option value="<?=$tv[$i]?>"><?=$tv[$i]?></option>
  <?}?>
  </select>
  </td>
 </tr>
 <tr>
  <td bgcolor="#ffffff" align="center"><input type="button" value="적용" onClick="fn_b()"></td>
 </td>
 </tr>
 </form>
</table>
</body>
</html>

----------------------------------------------------------------------e

728x90
반응형

댓글