国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

javascript基礎:document對象

2024-04-27 15:06:28
字體:
來源:轉載
供稿:網友

document對象包含一些屬性,如:domain,referrer。

下面代碼遍歷了document中包含的所有對象,另外,打開一個新的窗口,在新的窗口中用document對象的open方法,打開新的文檔,在文檔里輸入了標簽,最后用close方法關閉文檔。

通過document.getElementById document.getElementsByName可以找到指定id或者屬性名稱的標簽。

代碼:

<!DOCTYPE HTML><HTML> <HEAD>  <TITLE id="title1"> New Document </TITLE>  <META CHARSET="gb2312">	<script language="javascript">		function openWinDoc()		{			myWin = window.open("","","width=500,height=500");			myWin.document.open("text/html","replace");			myWin.document.write("<html><head><title>新文檔</title></head>");			myWin.document.write("<body>這是一個新的文檔</body></html>");			myWin.document.close();		}		function getId()		{			var c = document.getElementById("title1").tagName;			alert("窗口標題:" + c);		}		function getName()		{			var c = document.getElementsByName("blist").length;			alert("按鈕個數:" + c);		}	</script> </HEAD> <BODY>	<input type="button" value="打開新窗口-文檔" onclick="openWinDoc()"><br><hr>	<input type="button" name="blist" value="用id獲取窗口標題的標簽" onclick="getId()"><br><hr>	<input type="button" name="blist" value="用name獲取button屬性名為blist的按鈕數量" onclick="getName()"><br><hr>  	<script language="Javascript">				/*		domain: 服務器的網域名		referrer: 連接這個網頁的url		title: 標題		url:網頁url		*/		for(o in window.document)			if(typeof(window.document[o]) != "unknown" )				window.document.write(o + ":->" + window.document[o] + "<br>");			else				window.document.write(o + ":-><br>");	</script> </BODY></HTML>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鄱阳县| 玉田县| 边坝县| 壶关县| 肃南| 安岳县| 铜川市| 寿阳县| 志丹县| 集贤县| 云和县| 瓦房店市| 本溪| 山西省| 广南县| 柳江县| 钟山县| 望江县| 兰坪| 青铜峡市| 昔阳县| 平南县| 莫力| 大厂| 金华市| 蓝田县| 沙湾县| 富阳市| 玉林市| 清新县| 丰宁| 德钦县| 仁布县| 甘孜县| 永康市| 墨竹工卡县| 贞丰县| 嘉荫县| 茶陵县| 石泉县| 佛坪县|