我有下面的脚本,我用它来将变量传递给URL。当我点击搜索按钮时,它会重定向到包含文本框中变量的URL,但我需要做的是在搜索框下方打开的iframe中打开页面,以便我可以再次搜索仍然可见的框。
任何帮助将不胜感激
非常感谢,
马丁。
P.S。我已从网址中删除了电子表格代码。
<!DOCTYPE html>
<html>
<body>
Search by word (case sensitive):<br>
<input type="text" id="urlInput" value="">
<input type="hidden" id="urlInput2" value="%22">
<button onclick="redirect()">Search</button>
<script>
function redirect() {
var url = "https://docs.google.com/spreadsheets/d/XXXXXXXXXXXXXXXXXX/gviz/tq?tqx=out:html&tq=SELECT%20*%20where%20B%20contains%20%22" + document.getElementById('urlInput').value + document.getElementById('urlInput2').value;
window.location=url;
}
</script>
</body>
</html>
答案 0 :(得分:1)
function redirect() {
var url = "https://docs.google.com/spreadsheets/d/XXXXXXXXXXXXXXXXXX/gviz/tq?tqx=out:html&tq=SELECT%20*%20where%20B%20contains%20%22" + document.getElementById('urlInput').value + document.getElementById('urlInput2').value;
document.getElementById('iframe').src = url;
}
&#13;
#iframe {
width: 100%;
height: 80%;
}
&#13;
Search by word (case sensitive):<br>
<input type="text" id="urlInput" value="">
<input type="hidden" id="urlInput2" value="%22">
<button onclick="redirect()">Search</button>
<iframe src="https://cn.bing.com/?scope=web" id="iframe"></iframe>
&#13;