2012-07-10 39 views

回答

2

您拥有的getElementById引号括起来。

应该是:

<a href="" onclick="window.open('http://scholar.google.com/scholar?q=' + document.getElementById('keyword').value);"> 
+0

非常感谢! – campatsky 2012-07-10 20:19:29

3

您需要将document.getElementById('keyword')作为代码的一部分,而不是超链接。

<input type='text' name='keyword' id='keyword' size='16'> 

<a href= "" 
    onclick="window.open('http://scholar.google.com/scholar?q=' + document.getElementById('keyword') + '');"> 
+0

非常感谢你! – campatsky 2012-07-10 20:19:44

0

声明document.getElementById('keyword')不会自动给你写入的值。为此,你需要做document.getElementById('keyword').value

你可能想要做的是这样的:

<a onclick="window.open('http://scholar.google.com/scholar?q=' + document.getElementById('keyword').value);">Click here</a> 
+0

非常感谢! – campatsky 2012-07-10 20:19:39