<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
"m." + window.location.host + window.location.pathname
to the end whereas I just want to go to "m." + window.location.host + window.location.pathname
"m." + window.location.host + window.location.pathname
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;
您缺少协议 :
document.location = window.location.protocol + '//m.' + window.location.host + window.location.pathname;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.