0
我的網站項目存在另一個問題。確定這裏是我的問題...
從javascript函數向另一個javascript函數發送動態生成的值
<script>
function getTopArtist(){
if (window.XMLHttpRequest){
topartist = new XMLHttpRequest();
}
else{
topartist = new ActiveXObject("Microsoft.XMLHTTP");
}
topartist.onreadystatechange=function(){
try{
if (topartist.readyState==4 && topartist.status==200){
var ArtistDetails = topartist.responseXML.documentElement.getElementsByTagName("artist");
for(i=0;i<=2;i++){
myartistname = ArtistDetails[i].getElementsByTagName('name')[0].firstChild.nodeValue;
alert(myartistname)
document.getElementById('topartistdiv').innerHTML+='<a href="javascript:getAlbums(this is the proble here);">Albums</a>';
}
}
catch(er){
alert("Oops something went wrong!");
}
}
topartist.open("GET","http://localhost/test/topartist.php",true);
topartist.send(null);
}
</script>
我的問題是在第17行,當我試圖把藝術家姓名括號裏面的話,我可以將它們發送給另一個函數。所以我們假設它提醒Beyonce
我希望鏈接是這樣的。
javascript:getAlbums('Beyonce');
我想它與特殊字符有關,但我無法弄清楚。任何幫助將不勝感激。
會給我一個意外的標記catch錯誤的鉻。 – sam 2011-05-10 12:32:06