2011-02-19 84 views
0

這是我的功能更新SRC值螢火蟲跳「之後元素列表丟失)」時,有「)」

function browse(id,url){ 
     alert(url); 
     document.getElementById("main").value = url ;  
} 

我這是怎麼稱呼它:

<li style="min-width:350px;" title="click to play me"><a href="#" onclick="browse(68118,http://push2check.com/)" >' . $this->titulo . '</a><li> 

這是螢火蟲錯誤(corse警報從未執行):失蹤)參數列表後 [Interrumpir en este錯誤]瀏覽(68118,http://push2check.com/);

我不明白的是錯誤,是onclick好嗎?

回答

4

這是因爲這一點:

<a href="#" onclick="browse(68118,http://push2check.com/)" >' . $this->titulo . '</a> 

該URL需要被表示:

<a href="#" onclick="browse(68118,'http://push2check.com/')" >' . $this->titulo . '</a> 

你給一個「點擊」屬性必須是一個有效的HTML屬性值包含值有效的JavaScript。如果你寫道:

<script> 
    var x = http://push2check.com/; 

你可能不會期望工作; URL語法並不意味着任何直接針對JavaScript的東西,所以這將是一個語法錯誤。

+0

:$ thankyou!如此明顯! – 2011-02-19 02:50:42