Reputation: 114
I want to search in google the value of x. It doesn't work with this code:
function func2(){
var x = document.getElementById("gsearch").innerHTML;
window.open("http://www.google.com/#q="+x,"_self");
}
Upvotes: 1
Views: 403
Reputation: 45
Sorry for posting in a old question.
You can do that with the <form>
tag.
<form action="https://www.google.com/search">
<input type="search" name="q">
<input type="submit" value="Search">
</form>
Upvotes: 1
Reputation: 4054
Maybe you want to open a new tab with a Google Search?
Something like:
function func2() {
var x = document.getElementById("gsearch").value;
OpenInNewTab("http://www.google.com/custom?q=" + x);
}
function OpenInNewTab(url) {
var win = window.open(url, '_blank');
win.focus();
}
Upvotes: 0