-2

我有以下脚本,它不起作用。我该怎么做才能添加链接?jno = "97856483"; dispTitle = "新书"; dispAuthor = "作者名";

document.getElementById('popups').innerHTML = '';
//Add link to add this book:
 var url = encodeURIComponent(jno) + "&tt=" + encodeURIComponent(dispTitle) + "&at=" + encodeURIComponent(dispAuthor);
 //document.writeln(url);
 document.getElementById("addLink").innerHTML = "<a href='memaccountentry.php?isbn='+ url>Add book</a>" ;   //This one just appends the word url.
//window.location.href =  'memaccountentry.php?isbn=' +jno +'&tt=' +dispTitle+'&at=' +dispAuthor;          //I know this is working, but not a right way to do. 
//I need to put a href link to go to the next page. 
//ajax.open('GET', 'memaccountentry.php?isbn=' +jno +'&tt=' +dispTitle+'&at=' +dispAuthor', true);  
4

2 回答 2

4

您需要正确打开和关闭报价。
试试看:

document.getElementById("addLink").innerHTML = "<a href='memaccountentry.php?isbn="+ url +"'>Add book</a>" ;   //This one just appends the word url.
于 2012-06-28T21:23:30.160 回答
1

看来您的字符串格式不正确。

如果这不是你想要的,那么你让我完全糊涂了。

document.getElementById("addLink").innerHTML = "<a href='memaccountentry.php?isbn='" + url + ">Add book</a>";
于 2012-06-28T21:25:37.277 回答