【发布时间】:2017-09-11 05:37:54
【问题描述】:
我有这个代码:
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || ''
);
}
在我的 HTML 中,我使用以下方法标注了用户的设备品牌和型号:
<script>document.write(getURLParameter("brand") + (" ") + getURLParameter("name"))</script>
唯一的问题是这仅适用于某些移动设备。当它不起作用时,它只是留空。如果默认值是空的,有没有办法添加默认值?
【问题讨论】:
标签: javascript url parameters parameter-passing url-parameters