从URL抓取哈希? [英] Grabbing hash from URL?

查看:129
本文介绍了从URL抓取哈希?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要它,以便有人访问:

I want it so that if someone visits:

http://www.site.com/#hash

它将散列后的数据放入ID为url

It puts the data after the hash into the input box with the id url

然后提交表单.

这是我的代码:

<form method="post">
    <input id="url" placeholder="Enter" name="url">
    <input type="submit" id="visit" value="Visit" class="submit">
</form>

我该怎么做?

推荐答案

您可以使用

    if( window.location.hash) {
         var hashVal = window.location.hash.substring(1);
          $("#url").val(hashVal );
      } else {
          alert("no hash found");
      }

这篇关于从URL抓取哈希?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆