2011-02-02 88 views
2

目標頁面上一個javascript鏈接與JS鏈接:
dest.htm
鏈接到另一頁

<html> 
.. 
<a href="javascript:function(parameters);">JS LINK</a> 
.. 
</html> 

原始頁:
origin.htm

<html> 
.. 
<a href="dest.htm">Destination page</a> 
.. 
</html> 

目前,我正在鏈接到目標頁面。用戶必須手動點擊JS功能鏈接。我是否可以鏈接到目標頁面,以便在頁面加載時啓動相應的功能?

回答

2

也許<body onload="your_function()">上的一個dest.html就足夠了? :)

2

不直接。但是您可以撥打特定的querystring來呼叫該網站,這可以在您的目標網頁中通過您的javascript檢測到。

origin.htm

<a href="dest.htm#foo">Destination page</a> 

dest.htm

<script> 
    if(location.hash === '#foo') { 
     yourfunction(); 
    } 
</script>