Reputation:
<script type="text/javascript">
//deaktop = "m." + window.location.host + window.location.pathname;
if ($(window).width() < 989) {
document.location = "m." + window.location.host + window.location.pathname;
}
</script>
So my script seems to be getting the current URL then adding "m." + window.location.host + window.location.pathname
to the end whereas I just want to go to "m." + window.location.host + window.location.pathname
Upvotes: 0
Views: 34
Reputation: 5705
You're missing the protocol:
document.location = window.location.protocol + '//m.' + window.location.host + window.location.pathname;
Upvotes: 0
Reputation: 2446
Your problem is with the 'http' protocol and, maybe, with the 'www' too.
Try this:
var url = window.location.protocol+"//m."+ window.location.href.replace('http://', '').replace('www.', '');
window.location.href = url;
Upvotes: 1