检测当前页面是 GET 请求还是 POST 请求结果的书签
我正在尝试制作一个书签,它仅在 Firefox 3 中使用。如果使用它的页面是 GET 请求的结果,我希望它做一件事,如果它是在提交 POST 后生成的,则做另一件事要求。 具体来说,我试图确定是否可以通过访问地址栏中的 URL 来拉出同一页面。 像这样的事情:
if (whatever) {
alert("This page was produced by a get request.");
} else {
alert("This page was produced by a post request.");
}
我只需要知道如何测试它。
I am trying to make a bookmarklet, which will be used only in Firefox 3. I want it to do one thing if the page it is used on was the result of a GET request, and another thing if it was produced after submitting a POST request. Specifically, I am trying to determine whether I can pull up the same page by accessing the URL that is in the address bar. Something like this:
if (whatever) {
alert("This page was produced by a get request.");
} else {
alert("This page was produced by a post request.");
}
I just need to know how to test for it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道你有什么方法可以将其作为书签来执行此操作,但是有一个 Firefox 插件可以为你提供此信息 - http://livehttpheaders.mozdev.org/ 您可以查看该加载项的源代码,看看是否可以修改它以创建自己的加载项来执行您想要的操作脱离他们的代码。
I don't know of a way for you to do this as a bookmarklet, but there is a Firefox addin that can give you this information - http://livehttpheaders.mozdev.org/ You could take a look at the source of that add-in and see if you can modify it to create your own add-in to do what you want based off of their code.
我很确定 javascript 无法检测到使用了什么 HTTP 动词。
I'm pretty sure javascript can't detect what HTTP verb was used.