如何在Java脚本的超链接中传递多个参数?

南德

我正在尝试使用JavaScript创建动态超链接。我正在使用“&”传递多个参数,但是ii出现了解析错误。

JavaScript:

<script>
    function visitPage() {
        var phn = document.getElementById("bid").value;
        var totalprice = spans[3].innerHTML;
        window.location.href = 'https://www.instamojo.com/stayuncle/payments-for-stayuncle?data_amount='
            + totalprice + '&' + 'data_Field_68092=' + phn;
    }
</script>

错误:

实体名称必须紧跟在实体引用中的“&”之后。

我试图通过传递来修复它'&AMP',这导致链接看起来像这样:https://www.instamojo.com/stayuncle/payments-for-stayuncle/?data_amount=1374.75&AMPdata_Field_68092=Hotel%20Delhi%20Airport%20Link

' &AMP '仍然处于链接中,而不是转换为与号本身。

;每次删除&AMP我还删除了分号(,因为它不允许我发布实际的问题。

Vinayakj

var a = 1374.75;
var b = 'Hotel Delhi Airport Link';
var url = 'https://www.instamojo.com/stayuncle/payments-for-stayuncle'
var link = decodeURIComponent(url+'?data_amount='+a+'&data_Field_68092='+b)

alert("Redirecting to"+ link)
location.href = link

Alsso需要<![CDATA[ code //]]>像使用Thymeleaf一样包装代码

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章