Skip to main content
January 21, 2010
Answered

losing form elements and referer when opening in a javascript window

  • January 21, 2010
  • 2 replies
  • 2496 views

I am submitting from a.cfm to b.cfm. b.cfm opens in a Javascript window. In b.cfm, the form elements from a.cfm are lost and cgi.referer returns nothing.

When I don't open b.cfm in a Javascript window, everything is ok.

What is this happening?

This topic has been closed for replies.
Correct answer BKBK

BKBK, Sorry that I seemed discourteous. I never meant to be.

The "more script" was just my latest tries.

g() works tags inside or out but thank you for the suggestion about putting the tags outside.

Still don't understand why f() won't work when opening a new window but does work when not opening a new window.

Again,I guess I should've acknowleged each of your replies as they came. I really do appreciate your time and effort.


Perhaps, even neater:

function f(nextpg_,nextwin_)
         {
            var _attrs='';
            var _br=navigator.appName;
            document.forms[0].method="post";
            document.forms[0].action=nextpg_;
            document.forms[0].target=nextwin_;

etc., etc

}

2 replies

BKBK
Community Expert
Community Expert
January 25, 2010

I am submitting from a.cfm to b.cfm. b.cfm opens in a Javascript window. In b.cfm, the form elements from a.cfm are lost and cgi.referer returns nothing. When I don't open b.cfm in a Javascript window, everything is ok.

What is this happening?

The reason is simple really. Your code does not submit the form! Replace your Javascript with the following, and you will see it for yourself

<script language="javascript">
     function fie_(nextpg_,nextwin_)
     {
        var _attrs='';
        var _br=navigator.appName;
        if (_br=='Microsoft Internet Explorer')
        {
            _attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
            _attrs=_attrs+'top=0,left=0';
            window.opener=null;
            // window.close();
             // window.open(nextpg_,nextwin_,_attrs)

        }
        else
           {
              alert('Internet Explorer Please.')
           }
         // submit form to the page nextpg_
          document.forms[0].action=nextpg_;

     }
</script>

January 28, 2010

Should have seen that. Tried putting action in but no luck.Also tried putting in method="post" in form tag. Still cannot get value to next page. Any suggestions would be appreciated.

BKBK
Community Expert
Community Expert
January 29, 2010

When I use your code, plus the modified script I showed in my last post, the values appear on the action page. Start from there.

Inspiring
January 21, 2010

Hi,

Can you please post your complete code here?.

January 21, 2010

NOw it is aa.cfm and bb.cfm. aa.cfm is the first one, bb.cfm the second one.

<html>
   <head>
      <script language="javascript">
         function fie_(nextpg_,nextwin_)
         {
            var _attrs='';
            var _br=navigator.appName;
            if (_br=='Microsoft Internet Explorer')
            {
                _attrs='height='+screen.height+',width='+screen.width+'toolbar=0,menubar=0';
                _attrs=_attrs+'top=0,left=0';
                window.opener=null;
                window.close();
                window.open(nextpg_,nextwin_,_attrs)
            }
            else
               {
                  alert('Internet Explorer Please.')
               }
         }
      </script>
   </head>
   <body>
      <form>
         <input name="aabb" type="text" value="0">
         <input type="submit" value="*" onClick="fie_('bb.cfm','x')">  <!---  onClick="fie_('bb.cfm','x')" --->
      </form>
   </body>
</html>

<html>
   <head>
      <title>
      </title>
<!---      <meta http-equiv="refresh" content="5"> --->
   </head>
   <body>
      <cfoutput>
         ___*#aabb#*___*#cgi.referer#*___*#cgi.script_name#*___*#now()#*
      </cfoutput>
      <form>
         <input type="submit" value="**">
      </form>
   </body>
</html>

Inspiring
January 22, 2010

It's because you are using javascript.  If you really need a new window, target = "blank" is a lot simpler.