2014-01-05 22 views
0

我有一個主要的頁面:我想捕捉的對象標記事件

<script src='js/jquery-1.10.2.js'></script> 

<script> 
    $(document).ready(readyFn); 

    function readyFn() { 
     $('#cartelera01').attr('data','prueba5.html'); 

     function doSomething(){ 
      console.log('do something when the event of the object is triggered'); 
     } 
    } 
</script> 

<html> 
    <body> 
     <div> 
      <object id="cartelera01" type="text/html" data="" width="500" height="300" style='overflow-x: hidden;overflow-y: hidden;' 
        onpagehide="doSomething()" 
      ></object> 
     </div> 
    </body> 
</html> 

,並有prueba5.html太:

script src='js/jquery-1.10.2.js'></script> 
<script> 
    $(document).ready(readyFn); 

    function readyFn() { 
     console.log('page init'); 
     setTimeout(function() 
      { 
       console.log('after 3 seconds, page end'); //here I want to fire event object of principal page 
      }, 3000); 
    } 
</script> 

<html> 
<body> 
    <div style="left:0;width:300;heigth:200;background:black;"> 
     <img src="bola1.png" style='top:0;left:0px;width:180;height:180px;position:absolute;'> 
    </div> 
</body> 
</html> 

我想,當頁面prueba5.html結束自動(3秒後),主頁的對象「cartelera01」知道頁面prueba5.html已經結束,並且執行某些操作。 任何人都可以幫助我嗎? 在此先感謝。

+0

使用ajax或在您的主頁中運行prueba5.html作爲隱形iframe,對您有意義嗎? – Godinall

回答

0

你試過想想Ajax做你想做的事嗎? 使用Ajax,您可以撥打電話的網頁加載其他頁面而不必改變主網頁的標題,然後在結束時,您可以生成通知的響應...

看到的例子Here

+0

頁面prueba5.html有JavaScript代碼。這不僅是HTML網頁...我探討了它,但不起作用。如果它只是HTML工作正常,但我需要JavaScript代碼.... – user3158868