<script type="text/javascript">
window.onload = init;
function init() {
var button = document.getElementById("searchbutton");
button.onclick = handleButtonClick;
}
function handleButtonClick(e) {
var textinput = document.getElementById("searchinput");
var searchterm = textinput.value;
window.location.assign("http://www.google.com/testing/" + searchterm)
}
</script>
<input type="text" name="search" id="searchinput">
<button type="button" id="searchbutton">Ara</button>
This code block takes a user input and goes a new page with that.
When user pressed enter key, I want to make same thing with that submit button. I find something on web but they are all related with jquery.
I think you should use a tag, with a Submit button, and use the .onSubmit() event of the form. This event will be triggered both when you click and when you hit the Return (Enter) key.
An example JS code (tested in JSFiddle, just modified a bit your code to add a form) :
You can watch this code live here : http://jsfiddle.net/UD8FN/
Hugo,