JavaScript 小书签和 URL 编码
完全公开我不知道 Javascript,我正在尝试获取此 Javascript:
javascript:location = 'http://validator.w3.org/check?uri=' +escape(location)&doctype=Inline&charset=detect+automatically&ss=1&group=0&user-agent=W3C_Validator/1.654';
作为 Bookmarklet 工作,以便发送此格式的 URL:
http://validator.w3.org/check?uri=http://www.wordpress.org&charset=%28detect+automatically%29&doctype=Inline&ss=1&group=0&user-agent=W3C_Validator%2F1.654
到 W3C valdiator。
我使用这个编码器对Javascript进行URL编码,但是当然,我正在做出了问题,无论是在我的 JavaScript 中还是在编码过程中。
有人对 Javascript 书签和 URL 编码有一些特别或一般的想法吗?谢谢。
Fully disclosing that I do not know Javascript, I'm trying to get this Javascript:
javascript:location = 'http://validator.w3.org/check?uri=' +escape(location)&doctype=Inline&charset=detect+automatically&ss=1&group=0&user-agent=W3C_Validator/1.654';
to work as a Bookmarklet in order to send a URL of this format:
http://validator.w3.org/check?uri=http://www.wordpress.org&charset=%28detect+automatically%29&doctype=Inline&ss=1&group=0&user-agent=W3C_Validator%2F1.654
to the W3C valdiator.
I'm URL encoding the Javascript with this encoder, but of course, I'm doing something wrong, either in my Javascript or in the process of encoding it.
Anyone have some ideas in particular or in general about Javascript bookmarklets and URL encoding? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个错误:
您需要访问位置对象的“href”成员:
window.location.href = http://foo.com
您的 JavaScript 无效:
javascript:location = 'http://validator.w3.org/check?uri=' +escape(位置)此处缺少加号和引号&doctype=Inline&charset=自动检测&ss=1&group=0&user-agent=W3C_Validator/1.654';
我建议使用这个:
Two Errors:
You need to access the "href" member of the location object:
window.location.href = http://foo.com
You have invalid JavaScript:
javascript:location = 'http://validator.w3.org/check?uri=' +escape(location)PLUS SIGN AND QUOTE MISSING HERE&doctype=Inline&charset=detect+automatically&ss=1&group=0&user-agent=W3C_Validator/1.654';
I recommend using this: