Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
301 views
in Technique[技术] by (71.8m points)

javascript - Window.Open POST

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 .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You cannot trigger a javascript popup and then force a post request.

Three options:

  1. Trigger a POST form with target="_blank" using javascript (but this doesn't allow you to disable interface elements such as the menu bar).
  2. 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");
    
  3. 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.

  4. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...