728x90
728x90

html 문서간 변수값 주고받기를 JS만으로 동작한다.

 

출처 : javascript만으로 html간 변수값 주고받기

- http://blog.daum.net/jhmoon77/17455746
- http://blog.naver.com/music_2004?Redirect=Log&logNo=120121496301

 

 

 

 

 

1. 보내는 html

 

<script language = "javascript">
  name = "Hey"
  content = "Fighting!!!"
  location.href="5.html?" + name + ":" + content
</script> 
<html>
<head>
  <script language = "javascript">
    function sendFunc( aValue )
    {
    name="You_are_working_well." ;
    jumsu=100;
    location.href="receive.html?"+name+":"+jumsu;
    }
  </script>
</head>

<body>
<h1>sending</h1>
  <ul class="list1">
    <li>
    <!-- <a href="5.html" onClick='location.href="5.html?1:3:1"' class="lnk"> -->
      <a href="#" onclick="javascript:sendFunc('1:3:1')" class="lnk">
        <span class="fl">
        	<img height="55" width="55" alt="이미지" src="img/seasonal/1.jpg" />
        </span>
        <span class="fl2">
        <br>
        <font size="4"><strong class="ells">계절회무침</strong></font>
        </span>
      </a>
    </li>
  </ul>
</body>
</html>

 

 

 

2. 받는 html

 

<script language = "javascript">
  temp = location.href.split("?");
  data=temp[1].split(":");
  name = data[0];
  content = data[1];
  document.write(name + " " + content);
</script>
<html>
<head>
  <script language = "javascript">
  temp = location.href.split("?");
  data=temp[1].split(":");
  name = data[0];
  content = data[1];
  document.write(name + " " + content);
  </script>
</head>
<body>
	<h1>receiving</h1>
</body>
</html>

 

728x90
728x90
블로그 이미지

coding-restaurant

코딩 맛집에 방문해주셔서 감사합니다.

,

v