[範例] 欲傳送值,但不換頁的方法
test.html
<html>
<head><title>test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<frameset cols="50%,*">
<frame src="test1.html">
<frame name="rightFrame" src="test2.html">
</frameset>
</head>
<body>
</body>
</html>
test1.html
<html>
<head><title>Sample-1</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript">
function test(){
var obj=parent.rightFrame.document.dataForm.content.value;
if(!obj.match(""+document.getElementById("sel").value+"")){
parent.rightFrame.document.dataForm.content.value+=document.getElementById("sel").value+"\r\n";
}
}
</script>
</head>
<body>
<select id="sel">
<option value="php">php</option>
<option value="javascript">javascript</option>
</select>
<input type="button" value="傳送" onclick="test()">
<!-- <input type="image" src="圖片所在位置"> -->
</body>
</html>
test2.html
<html>
<head><title>test</title>
<meta http-equiv="content-type" content="test/html; charset=utf-8">
</head>
<body>
<form name="dataForm">
<textarea cols="20" rows="20" id="content" name="content"></textarea>
<input type="reset" value="清除">
</form>
</body>
</html>
節錄自: 藍色小舖
沒有留言:
張貼留言