我有以下脚本,但无效。我该怎么做才能添加链接? jno =“97856483”; dispTitle =“新书”; dispAuthor =“authorname”;
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);
答案 0 :(得分:4)
您需要正确打开和关闭报价 试试这个:
document.getElementById("addLink").innerHTML = "<a href='memaccountentry.php?isbn="+ url +"'>Add book</a>" ; //This one just appends the word url.
答案 1 :(得分:1)
看起来你没有正确格式化你的字符串。
如果这不是你想要的,那么你让我完全糊涂了。
document.getElementById("addLink").innerHTML = "<a href='memaccountentry.php?isbn='" + url + ">Add book</a>";