不能这么做<iframe id=js1 src="www.51js.com" onload="loadFun(this)">
</iframe>
<script>
function loadFun(obj)
{
alert(obj.id);
}
</script>
</iframe>
<script>
function loadFun(obj)
{
alert(obj.id);
}
</script>
</iframe>
<script>
function loadFun(obj)
{
alert(obj.id);
}
</script>为什么不可以?
---------------------
"不能这么做"
几个字是拷楼主的贴时,忘了删的
</iframe>
这种方法是不可以的我需要
<iframe id=js2 src="www.51js.com" onload="load()">
</iframe><script>
function load()
{
alert(this.id);
}
</script>这种解决方式
</iframe><script>
function load()
{
if(event.srcElement.id != null)
alert(event.srcElement.id);
}
</script>
<!--
function t_1(){
CallLevel()
}
function t_2(){
CallLevel()
}
function CallLevel(){
var s=CallLevel.caller.toString();
var fn=s.substring(s.indexOf(" ")+1,s.indexOf(")")+1);
if (fn == "anonymous()")
alert("没有被其他函数调用.");
else
alert("被 "+fn+" 调用")
}//-->
</script>
<input type="button" id="B1" value="B0" onclick="CallLevel()">
<input type="button" id="B1" value="B1" onclick="t_1()">
<input type="button" id="B2" value="B2" onclick="t_2()">
请注意,用的是:
alert(obj.id);
而不是
alert(this.id);