向URL重定向添加查询字符串
Add query string to URL redirect
我试图使用查询字符串,我可以成功做到,除非它是一个移动页面。我正在做的是检查它是否移动和重定向。是否有办法将查询字符串附加到重定向url?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">// <![CDATA[
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows'sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
document.location = "http://www.xxxxxxx.com/mobile";
}
// ]]></script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xxxxxxxxx</title>
<script type="text/javascript">
window.onload = function(){
var total = 0;
for(var x = 0; x < parameters.length; x++){
document.getElementById("customerID").value = parameters[x].value;
}
document.forms[0].onsubmit = validate;
}
</script>
我想这可能是你想要的。
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows'sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
window.location = "http://www.xxxxxxx.com/mobile" + window.location.search + window.location.hash;
}
我将其简化为window.location.search是一个空白字符串或以?开头。.hash
也是一样如果您的起始URL是http://www.some.com/entry?id=10,那么重定向将是http://www.some.com/mobile?entry?id=10
哈希
也是一样http://www.some.com/entry?id=10 paragraph2会重定向到http://www.some.com/mobile?id=10 paragraph2
如果当前URL不包含任何一个,则重定向URL将保持原样
相关文章:
- 如何有效地将游戏数据存储在URL查询字符串中
- 从查询字符串参数推断出正确的数据类型
- AngularJS:获取链接中没有哈希的查询字符串值
- AngularJS,如何更改查询字符串
- 如何将activeadmin查询字符串传递给batch_action
- 如何从查询字符串中的输入字段发回文本
- Django在使用AJAX时没有接收到新的查询字符串
- 使用查询字符串方法清除浏览器缓存
- 用于刷新的Javascript更改查询字符串
- 我想将查询字符串变量添加到JSON名称/值对中
- 将查询字符串值从页面传递 asp.net 到 iframe
- jqueryajax生成查询字符串,如果未定义则不通过
- 如何将查询字符串传递到HTML框架
- AngularJs将查询字符串发布到c#控制器
- Jquery - 从查询字符串中获取“#”值之后,而不是在“?”符号值之后获取
- 在 JavaScript 中将查询字符串传递给 Web 服务 (ASP.NET)
- 在查询字符串中查找 where 子句
- POST encodeURI查询字符串内部服务器错误 500
- JavaScript:从具有使用 # 符号的路由的 URL 获取查询字符串
- 更改链接 URL 中的路径名,同时保持查询字符串不变