網(wǎng)頁中嵌入另一個(gè)網(wǎng)頁
網(wǎng)頁中嵌入另一個(gè)網(wǎng)頁<IFRAME align=center marginWidth=0 marginHeight=0 src="此處網(wǎng)址" frameBorder=0 width=200 scrolling=no height=100></IFRAME>
網(wǎng)頁中獲取嵌套IFRAME中的標(biāo)簽值
關(guān)鍵字: iframe,標(biāo)簽網(wǎng)頁中經(jīng)常要嵌套一些iframe,在提交表單的時(shí)候,還需要把iframe中的值取出來,和父頁面的form一起提交,很麻煩,好不容易找了個(gè)方法,做個(gè)筆記:
<iframe src="" name="iframe"/>
<script type="text/javascript">
var tag= document.frames['iframe'].tagname;
</script>
tagname就是iframe頁面中的標(biāo)簽的名稱,這樣就能獲取到要獲取的值,跟在父頁面一樣處理。
<iframe src="" name="iframe"/>
<script type="text/javascript">
var tag= document.frames['iframe'].tagname;
</script>
tagname就是iframe頁面中的標(biāo)簽的名稱,這樣就能獲取到要獲取的值,跟在父頁面一樣處理。
在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 是獲取以指定名稱命名的對象數(shù)組,
那個(gè)頁里只包含一個(gè)以"BH"命名的textbox,所以就要加上"[0]"這個(gè)了
[0]就表示數(shù)組的第一個(gè)對象
posted on 2008-08-14 15:13 半導(dǎo)體 閱讀(722) 評論(0) 編輯 收藏 所屬分類: HTML