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

4

2 回答 2

0

open()方法采用第二个name参数,您可以将其用作帖子的目标,因此您可以创建一个带有目标的隐藏表单,使用about:blank目标名称打开并提交该表单。

或者你可以有一个提交到特殊的“_blank”目标的表单,它也会打开一个窗口。同样,您以编程方式填写并提交表单。

编辑:我说'_new'这是错误的......

于 2013-08-21T18:35:58.677 回答
0

您可以按照此大纲来实现您的目标:

  1. 在您的 HTML 中创建一个小表单,将其action属性设置为CompleteProfileDisplay.jsp,其中包含一个名为 的输入字段email,其中一个target_blank,一个methodpost

  2. 让您的函数email将此表单的输入字段的值设置为给定的电子邮件地址并提交表单。

  3. 将打开一个弹出窗口,其中包含与您的原始请求相同的结果,但数据(电子邮件地址)将作为POST请求提交,而不会在 URL 中显示。

像这样:

 <!-- 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>

(您的问题并未表明您正在以任何方式自定义弹出窗口的外观,因此我没有在回答中考虑这一点。)

于 2013-08-21T18:39:35.587 回答