我正在尝试使用此脚本将任何网页重定向到另一个网页,其中包含上一个网页的网址查询。
我试图使用的代码如下:
window.location = "http://www.readability.com/m?url=" + document.URL;它不起作用,出于什么原因我无法弄清楚。 我不熟悉编码,所以这可能是问题所在。 这有效......
window.location = "http://www.readability.com"但这不起作用
window.location = "http://www.readability.com/"Furthmore我正在使用移动浏览器,而不是像chrome这样的东西。 所以它可能只是一个问题,但它可能不是。 感谢您的阅读,并提前感谢您的帮助。
I'm trying to use this script that will redirect any webpage to another webpage with a query including the previous webpage's URL.
The code I'm attempting to use looks as such:
window.location = "http://www.readability.com/m?url=" + document.URL;It's not working though, for what reason I can't figure out. I'm not to familiar with encoding, so this may be the problem. As this works...
window.location = "http://www.readability.com"But this does not work
window.location = "http://www.readability.com/"Furthmore I'm working with a mobile browser, not anything like chrome. So it may just be an issue with that, but it may not be. Thanks for reading, and thanks in advance for any help.
最满意答案
你需要转义URL,否则它将被剪切在第一个&它包含。
window.location = "http://www.readability.com/m?url=" + encodeURIComponent(window.location);也忽略document.URL并使用更常见且可互操作的window.location 。
You need to escape the URL, otherwise it will be cut on the first & it contains.
window.location = "http://www.readability.com/m?url=" + encodeURIComponent(window.location);also ignore document.URL and use a more common and interoperable window.location instead.
更多推荐
发布评论