您好,我想知道是否有可能,因为我已经完成了google脚本教程中的边栏示例,所以当我们单击用Google搜索打开的标签时,我已经链接到google网站。
我的问题是,可以单击并在侧边栏中搜索Google页面,然后在此处进行搜索吗?谢谢。
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
Click <a href="https://www.google.com/" target="_blank">here</a> for a google search
<input type="button" value="Ferme"
onclick="google.script.host.close()" />
</body>
</html>
答案 0 :(得分:1)
此脚本将从输入框中获取搜索词组,并打开一个包含结果的新标签:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function doSearch() {
var searchFor = document.getElementById("txtSearchFor").value;
window.open("https://www.google.com/search?q=" + searchFor);
}
</script>
</head>
<body>
<H1>Sidebar</H1>
<input type="text" id="txtSearchFor"/>
<input type="button" value="Search" id="btnSearch" onclick="doSearch()"/>
</body>
</html>
如果您想对结果进行实际处理,那么应该考虑使用google custom search api,它会涉及更多的内容。