0

I have this piece of JavaScript code:

 <script language="javascript">
    function editRecord(email){
        window.open('CompleteProfileDisplay.jsp?email='+email);
        f.submit();
    }         
</script>

My question is how to hide the email value in address bar while calling CompleteProfileDisplay.jsp page through window.open function. One more thing CompleteProfileDisplay.jsp accepting the email value as request.getParameter method. Please help me if anybody is having an idea.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

0

The open() method takes a second name parameter which you can use as the target of a post, so you can create a hidden form with a target, open about:blank with a the target name and submit that form.

Or you can have a form that submits to the special '_blank' target which also opens a window. Similarly you programmatically fill and submit the form.

Edit: I said '_new' which is wrong....

billc.cn
  • 7,187
  • 3
  • 39
  • 79
0

You can follow this outline to accomplish your goal:

  1. Create a small form within your HTML, with its action property set to CompleteProfileDisplay.jsp, containing an input field named email, with a target of _blank, and a method of post.

  2. Have your function set the value of the email input field of this form to the given email address and submit the form.

  3. A popup window will open containing the same results as your original request, but the data (email address) will be submitted as a POST request without being visible in the URL.

Like this:

 <!-- make sure this form isn't nested with another form in your page -->
 <form action="CompleteProfileDisplay.jsp" target="_blank" method="post">
 <input type="hidden" name="email" id="hiddenemail" />
 </form>
 <script>
     function editRecord(email){
         var e = document.getElementById('hiddenemail');
         e.value = email;
         e.form.submit();
     }    
 </script>

(Your question does not show that you are customizing the popup window's appearance in any way, so I am not considering that in my answer.)

Joseph Myers
  • 6,434
  • 27
  • 36