I am trying to use a query string which I can successfully do unless it is a mobile page. What I am doing is checking if it is mobile and redirecting. Is there a way to attach the query string to the 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>
You can use URL Redirect to forward your visitors to a specific page at the destination URL and pass values via query strings to the destination.
pathname. The pathname property of the URL interface is a string containing an initial / followed by the path of the URL, not including the query string or fragment (or the empty string if there is no path).
On the internet, a Query string is the part of a link (otherwise known as a hyperlink or a uniform resource locator, URL for short) which assigns values to specified attributes (known as keys or parameters). Typical link containing a query string is as follows: http://example.com/over/there? name=ferret.
I think this might be what you want..
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;
}
I simplified this as window.location.search is either a blank string or starts with ?. Same goes for .hash
If your starting URL was http://www.some.com/entry?id=10 the redirect would be http://www.some.com/mobile?entry?id=10
Same goes for hashes
http://www.some.com/entry?id=10#paragraph2 would redirect to http://www.some.com/mobile?id=10#paragraph2
If the current URL does not contain either the redirect URL will remain as is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With