我想輸入一個URL到一個表單文本輸入,並onBlur,更新所包含的iframe與網址中指定的網頁的內容。我似乎無法得到它的工作,我不明白爲什麼... :)JavaScript的onblur影響從文本框輸入到iframe?
有人可以幫助我嗎?
這裏是代碼...
<!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>
<meta http-equiv=」Content-Type」 content=」text/html; charset=iso-8859-1″ />
<script language="javascript" type="text/javascript" >
<!-- hide
function setIframeSource() {
var theSelect = document.getElementById('location');
var theIframe = document.getElementById('myIframe');
var theUrl;
theUrl = document.getElementById("location");
theIframe.src = theUrl;
}
// end hide -->
</script>
</head>
<body><center>
<form id="form1" method="post">
<input type="text" style="width:150px;" name="location2" id="location" onBlur="setIframeSource();">
</form>
<table width="100%" height="100%" border="1">
<tr>
<td width="300"><iframe src="http://www.ibm.com" id="myIframe" width="280" height="300" name="frame1"></iframe></td>
</tr>
</table>
</center>
</body>
</html>