Window.Open POST [英] Window.Open POST
问题描述
我有一个链接,当点击时,我打开一个带有window.open的窗口,如下所示。
I have a link which when clicked I open a window with window.open like below.
window.open("edit.jsp?clientId=" + clientId + "&eventId=" + eventId , 'height=600,width=800,scrollbars=1,location:no,menubar:no,resizable=1,status:no,toolbar:no');
我不希望参数传递到这里,而是我想要发布这样的东西,所以人们不能复制网址。
I dont want the parameter to pass here instead I want to something like post so people cant copy url .
推荐答案
您无法触发javascript弹出窗口然后强制发布请求。
You cannot trigger a javascript popup and then force a post request.
三个选项:
- 使用
target =_ blank触发POST表单
使用javascript(但这不允许您禁用菜单栏等界面元素)。 -
在本地打开弹出窗口,但不指定网址。使用window.open的结果来改变文档以生成一个表格,然后你发布。
- Trigger a POST form with
target="_blank"
using javascript (but this doesn't allow you to disable interface elements such as the menu bar). Open a popup locally, but don't specify a url. Use the result of window.open to alter the document to generate a form, which you'd then post.
var myWindow = window.open("", "", "height=600,width=800,scrollbars=1,location=no,menubar=no,resizable=1,status=no,toolbar=no");
myWindow.document.write("Write a form here and then later on trigger it");
你真的不应该这样做。如果用户复制网址不好,那么您的应用程序设计就存在缺陷。
You really shouldn't do any of this. If it's bad for users to copy urls, there's a flaw in your application design.
编辑后添加:使用空窗口方法,但不是编写表单并触发它,而是执行操作父级中的 XMLHTTPRequest
(带POST)。此请求的结果可用于填充子窗口。
Added after edit: Use the 'empty window' approach, but instead of writing a form and triggering it, do a an XMLHTTPRequest
(with POST) in the parent. The result of this request can be used to populate the child-window.
这篇关于Window.Open POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!