通过javascript函数预定义google搜索
我需要通过一个javascript函数进行预定义的Google搜索,该函数由页面中的一个按钮启动 所以我以前试过,但没有成功:通过javascript函数预定义google搜索,javascript,Javascript,我需要通过一个javascript函数进行预定义的Google搜索,该函数由页面中的一个按钮启动 所以我以前试过,但没有成功: <html> <head> <script language="JavaScript"> function googleSearch(quest){ var googlefind = "http://www.google.com/search?hl=en&q=" + quest + " buy Blu-Ra
<html>
<head>
<script language="JavaScript">
function googleSearch(quest){
var googlefind = "http://www.google.com/search?hl=en&q=" + quest + " buy Blu-Ray DVD";
window.open(googlefind);
}
</script>
</head>
<body>
<INPUT type="button" value="Buy this Anime Now!" onclick="googleSearch("Fullmetal Alchemist Brotherhood");">
</body>
</html>
谷歌搜索功能(quest){
var googlefind=”http://www.google.com/search?hl=en&q=“+quest+”购买蓝光DVD“;
打开(谷歌搜索);
}
有人能帮我吗?在你的函数中将escape()
添加到googlefind
,并在你的onclick
中将关键字改为单引号
<html>
<head>
<script language="JavaScript">
function googleSearch(quest){
var googlefind = quest + " buy Blu-Ray DVD";
window.open("http://www.google.com/search?hl=en&q=" + escape(googlefind));
}
</script>
</head>
<body>
<INPUT type="button" value="Buy this Anime Now!" onclick="googleSearch('Fullmetal Alchemist Brotherhood');">
</body>
</html>
谷歌搜索功能(quest){
var googlefind=quest+“购买蓝光DVD”;
窗口打开(“http://www.google.com/search?hl=en&q=“+逃逸(谷歌搜索));
}
另外,请记住,某些浏览器不喜欢当前定义的脚本标记方式。我将更改为type='text/javascript
,而不是language='javascript'
,如下所示:
<html>
<head>
<script type="text/javascript">
function googleSearch(quest){
var googlefind = quest + " buy Blu-Ray DVD";
window.open("http://www.google.com/search?hl=en&q=" + googlefind);
}
</script>
</head>
<body>
<INPUT type="button" value="Buy this Anime Now!" onclick="googleSearch('Fullmetal Alchemist Brotherhood');" />
</body>
</html>
谷歌搜索功能(quest){
var googlefind=quest+“购买蓝光DVD”;
窗口打开(“http://www.google.com/search?hl=en&q=“+谷歌搜索);
}
将传递参数中的双引号替换为单引号
onclick=“googleSearch(‘全金属炼金术士兄弟会’)太棒了,你做到了!谢谢你的帮助!