window.location.href="<?php echo $url?>"
如果是js本身的变量,则这样:
window.location.href=$url
//转码var url = encodeURIComponent("http://localhost:8888/xx/yy?a=aaa&b=bbb&c=ccc")
//解码
var ourl = decodeURIComponent(url)
另外还有encodeURI/decodeURI,escape/unescape,最常用的是encodeURIComponent
/decodeURIComponent它可以将参数中的中文、特殊字符进行转义,而不会影响整个URL。