Link to home
Start Free TrialLog in
Avatar of jimojeda
jimojeda

asked on

Autosubmit form to new popup window... how?

Hello,

This one is going to be a tricky one and I hope someone here can help me...

I have a hidden form on my site that's designed to submit a couple of hidden fields to a PHP script via the "Post" method.

The php script is called "track.php" it's merely for tracking purposes after a visitor orders so that I know which of all my tracking programs is going to record the "sale".

Anyway, every time a customer orders, when they get to the "thank you" page, I have to ask them to "click here" to activate your product, which is really so that the from submits to a new window the tracking details.

I want to make it automated so that it all happens in the background without my customer knowing it.  I already figured out how to "autosubmit" the form by using the following in the <body> tag: <body onLoad="document.form.submit()">

I already figured out how to have it open on a new window using this in the <form> tag: target="popup" onsubmit="window.open('', 'popup', 'width=100,height=100,scrollbars=yes,menubar=no,status=no');"

However, here is where the problem lies...

When you actually physically click on the form button, the popup window works and looks just like I want it to look, according to the specifications I placed above.  BUT, when I add the "onLoad="document.form.submit()" on the <body> tag, the page that opens is a regular window... just like when you use the "target=_blank" command.

I'd like the window that opens to be to have no menubar or status bar, yet it contains everything.

Below is the whole code and if anyone here can figure out how to make the autopopup work correctly, please let me know.

========== Whole page ==============

<html>
<head>
</head>
<body onLoad="document.form.submit()">
<form name="form" action="track.php" method="post" target="popup" onsubmit="window.open('', 'popup', 'width=100,height=100,scrollbars=yes,menubar=no,status=no');">
<input type="hidden" name="tra" value="1">
<input type="hidden" name="amount" value="1.00">
<input type="image" src="invisible.gif" border="0" name="submit">
</form>
</body>
</html>

========== End Whole Code ===============

Anyway, can someone figure out how it can autosubmit but at the same time respect the attributes on the window.open command?

Thanks,

Jaime

Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Look at this:

<html>
<head>
</head>
<body>
<form name="theForm" action="track.php" method="post" target="subFrame" >
<input type="hidden" name="tra" value="1">
<input type="hidden" name="amount" value="1.00">
<input type="image" src="invisible.gif" border="0" name="Submit">
</form>
<iframe name="subFrame" width="0px" width="0px" ></iframe>
<script>document.theForm.submit();</script>
</body>
</html>



Avatar of jimojeda
jimojeda

ASKER

Hi Zvonko,

Sorry, that doesn't work... here's why.

I forgot to mention that the "thank you" page is in a secure server: https

And the reason I need it to open an outside window is because the image tags embedded in the php file need to be accessed through a regular unsecure link.

By doing the <iframe>, it pulls the file into the secure window, and since the window within the <iframe> has images that need to be pulled through an unsecure channel, it creates a security warning.

So I think that the only way to not get that warning is to have it open a different window to post the details to.

Does that make sense?

Thanks,

Jaime
No, it does not.
The IFRAME is a separate window and therefore you do not get a mixture warning.
Check please wether this gives a warning to you:

<html>
<head>
<title>MIX</title>
</head>
<body>
<h1>My Page</h1>
<iframe src="https://www.experts-exchange.com/"></iframe>
<iframe src="https://www.experts-exchange.com/editPremiumServices.jsp"></iframe>
</body>
</html>

Zvonko,

You don't understand how this works.

Let me give you a live example I set up on my site.

Go to http://www.workfromhomespecials.com/iframe.html

Notice that when you go there, everything loads nicely.  Before you go anywhere else, here's what I want you to do...

Check out the source code on the page that loads in the <iframe> window.  Notice it has an image tag towards the bottom that looks like this:

<IMG width=1 height=1 src='http://www.workfromhomespecials.com/split/inc_counter.php?cid=2&amt=1&img=1'>

I have no choice there.  That image tag needs to be pulled through an un-secure channel "http".  If I pull it through the secure channel, "https", then the script won't register it as a hit.

Now, go to the same page I mentioned above, but like this now...

https://workfromhomespecials.com/iframe.html

Now, tell me what you get.

Do you see what I mean?  It doesn't matter weather the iframe pulls the page through a secure channel or not, what matters is the image tag on the track.html page.  Since the image tag needs to be pulled through an un-secure line, the <iframe> feature will never work simply because it's within the same main window on a secure site.  So again we come back to square one... how can we use javascript to submit the form to a completely new window?

Sincerely,

Jaime Ojeda
OK. Now I see your problem.
Now let us summerize:
1.) If you have a http page then is an https frame not a problem.
2.) If you have a https page then is a http element a warning.

Now, whatabout a http page containing an https iframe allover the page and a hidden iframe for the submit target?
I think that extra embedding is better then popups, alone because of the blockers.


Zvonko,

You still don't understand the whole concept.

It DOES NOT matter how many embedded IFRAMES you have on the page or whether the source page gets pulled through a secure channel or not.

What makes this whole think fall apart is the fact that the <img> tag on the "track.html" page needs to be inserted through a non-secure link.  Since that image tag is non-secure, it will always create a warning unless that form can be submitted into an entirely new window.

In other words, we have to make my code work somehow because it's a new window no matter what.

Jaime
I finally figured it out on my own.

I found out about a javascript function called autoClick() which did the job perfectly.

Thanks
fine for you.
ask here for question close: http:/Community_Support/askQuestion.jsp
ASKER CERTIFIED SOLUTION
Avatar of PAQ_Man
PAQ_Man
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial