<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>webkfa.com</TITLE> <SCRIPT LANGUAGE="JavaScript"> function test(){ //得到div层的对象 var obj=document.getElementById("testid"); //得到div层的name属性 var name=obj.getAttribute("name"); alert(name); } //网页加载完调用test方法 window.onload=test; </SCRIPT> </HEAD> <BODY> <div id="testid" name="webkfa"> </div> </BODY> </HTML>