开发者

Goto page with textfield value as hash

开发者 https://www.devze.com 2023-03-16 10:06 出处:网络
Ok, this should be easy but for me it doesn\'t seem so... probably because i\'m very close to the deadline and have a lot to do.

Ok, this should be easy but for me it doesn't seem so... probably because i'm very close to the deadline and have a lot to do.

This is what i'm trying to do; I have an html form with a textfield and a button - whenever the button is clicked or enter is pressed i would like it to goto a particul开发者_高级运维ar page with the text field's value on the end as a hash.

for instance; user enters "test" and presses enter or hits the button and the page goes to "google.com#test"


<html>
<head>
  <script type="text/javascript">
    function do_it() {
      var hash = document.getElementById("hash_input").value;
      window.location = "http://google.com#"+hash;
    }
  </script>
</head>
<body>

<input id="hash_input" type="text"></input>
<input type="button" onclick="do_it()" value="Go"></input>

</body>
</html>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号