İçeriğe atla
Ağustos 23, 2011 / sukruerdem

2 Frame arası Parametre gönderme

Bir sayfada 2 ayrı frame varsa ve bu iki frame arasında bir değer gönderimi işlemi yapılacaksa bir JavaScript kodu ile bunu gerçekleştirebiliriz. Aşağıda ilgili sayfa ve kod örneği görünmektedir.

Genel Sayfa:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<frameset rows="98,*" cols="*" framespacing="0" frameborder="no" border="1">
<frame src="LetterTop.html" name="TopFrame" scrolling="No" noresize="noresize" id="TopFrame" />
<frame src="LetterBody.html" name="BodyFrame" id="BodyFrame" />
</frameset>
<noframes><body>

</body></noframes>
</html>

Değeri gönderen Frame:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>
</head>

<body>
<form name="formone" id="formone">
<input type="text" name="mytextone" /><br />
<input type="text" name="mytexttwo" /><br />
<input type="button" onclick="store_info()" value="Submit" />
</form>
</body>
</html>

Değeri alan Frame:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="undefined">
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function store_info() {
parent.TopFrame.formone.mytextone.value = document.formtwo.test1.value;
parent.TopFrame.formone.mytexttwo.value = document.formtwo.test2.value;
}
</script>
</head>
<body>
<form name="formtwo" id="formtwo">
   Enter some text:
   <input type="text" name="test1" />
   <br />
   Enter some text:
   <input type="text" name="test2" />
   <p>
      <input type="button" value="Submit" onclick="store_info();" />
   </p>
</form>
</body>
</html>

Yorum yapın

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Değiştir )

Twitter picture

You are commenting using your Twitter account. Log Out / Değiştir )

Facebook photo

You are commenting using your Facebook account. Log Out / Değiştir )

Connecting to %s

Follow

Get every new post delivered to your Inbox.