如何剥离 ?url= 并设置为 href 变量?
我目前有这个 jquery 但它不起作用。如果它有帮助,我的网址是 http://link-ads.blogspot.com/
jquery 还会确保 href
具有 http://
> 如果 ?url=
中不存在
<script type='text/javascript'>
var url = "document.location.href"
url = url.split('?url=')[1].split(/\?|\%3F/)[0];
if (url.indexOf('http://') == -1) url = 'http://' + url;
$("a#download").attr("href",url);
</script>
<a href="" id="download" class="button">continue</a>
I currently have this jquery but it won't work. if it helps my url is http://link-ads.blogspot.com/
the jquery also makes sure the href
has http://
if not present in ?url=
<script type='text/javascript'>
var url = "document.location.href"
url = url.split('?url=')[1].split(/\?|\%3F/)[0];
if (url.indexOf('http://') == -1) url = 'http://' + url;
$("a#download").attr("href",url);
</script>
<a href="" id="download" class="button">continue</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个问题,
应该更改
我注意到在执行此行之前还
您应该确保这可以通过类似的操作实现,
否则您将得到异常,因为数组中不会有 [1] 元素
I notice two issues
should be changed to
also before you do this line
you should make sure that this is possible with something like
otherwise you will get an exception because there won't be a [1] element in the array