如何在javascript中问号后获取url值 [英] how to get url value after question mark in javascript
本文介绍了如何在javascript中问号后获取url值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在javascript中问号后获取url值?
How can I get the url value after a question mark in javascript?
我想要以下行为:
if value is yes then 10+2
else if value is no then 10.
我想输出警告消息.
<div class="col-xs-4 col-sm-4 col-md-4 text-center width100">
<a href="piccal.html" class="btn btn-success" id="yes">PIC Grant Calculator</a>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 text-center width100">
<a href="piccal.html" class="btn btn-danger" id="no">PIC Grant Calculator</a>
</div>
<script>
if (value == no) {
alert('hello');
}
</script>
<script>
if (value == yes) {
alert('hi');
}
</script>
推荐答案
使用以下代码:
var a = location.href;
var b = a.substring(a.indexOf("?")+1);
这篇关于如何在javascript中问号后获取url值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文