網(wǎng)頁(yè)中嵌入另一個(gè)網(wǎng)頁(yè)
<IFRAME align=center marginWidth=0 marginHeight=0 src="此處網(wǎng)址" frameBorder=0 width=200 scrolling=no height=100></IFRAME>
關(guān)鍵字: iframe,標(biāo)簽
網(wǎng)頁(yè)中經(jīng)常要嵌套一些iframe,在提交表單的時(shí)候,還需要把iframe中的值取出來(lái),和父頁(yè)面的form一起提交,很麻煩,好不容易找了個(gè)方法,做個(gè)筆記:
<iframe src="" name="iframe"/>
<script type="text/javascript">
var tag= document.frames['iframe'].tagname;
</script>
tagname就是iframe頁(yè)面中的標(biāo)簽的名稱,這樣就能獲取到要獲取的值,跟在父頁(yè)面一樣處理。
在Iframe中獲取父窗口中表單的值!
<from name="frm" action="bb.asp">
<table>
<tr>
<td><input type="text" name="BH"></td>
</tr>
<tr>
<td><iframe name="ScrollFrame" src="aa.asp" width="100%"></IFRAME></td>
</tr>
</table>
</form>
<script language="javascript">
function show(){
if(document.parentWindow.parent.document.getElementsByName("BH")[0].value=="")
alert("空的");
else
alert("不空");
}
</script>
<input type="button" value="show" onclick="show();">
getElementsByName 是獲取以指定名稱命名的對(duì)象數(shù)組,
那個(gè)頁(yè)里只包含一個(gè)以"BH"命名的textbox,所以就要加上"[0]"這個(gè)了
[0]就表示數(shù)組的第一個(gè)對(duì)象