不能这么做<iframe id=js1 src="www.51js.com" onload="loadFun(this)">
</iframe>
<script>
function loadFun(obj)
{
    alert(obj.id);
}
</script>

解决方案 »

  1.   

    <iframe id=js1 src="http://www.51js.com" onload="loadFun(this)">
    </iframe>
    <script>
    function loadFun(obj)
    {
        alert(obj.id);
    }
    </script>为什么不可以?
      

  2.   

    回复人: JK_10000(JK) ( ) 信誉:121  2004-11-04 13:33:00  得分: 0  
    ---------------------
    "不能这么做"
    几个字是拷楼主的贴时,忘了删的
      

  3.   

    晕啊,我没说清楚 <iframe id=js1 src="www.51js.com" onload="load(this)">
    </iframe>
    这种方法是不可以的我需要
    <iframe id=js2 src="www.51js.com" onload="load()">
    </iframe><script>
    function load()
    {
        alert(this.id);
    }
    </script>这种解决方式
      

  4.   

    <iframe id=js2 src="www.51js.com" onload="load()">
    </iframe><script>
    function load()
    {
       if(event.srcElement.id != null)
        alert(event.srcElement.id);
    }
    </script>
      

  5.   

    <script language="JavaScript">
    <!--
    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()">
      

  6.   

    用二楼的方法不对吗,
    请注意,用的是:
    alert(obj.id);
    而不是
    alert(this.id);