Forum Moderators: coopster & phranque

Message Too Old, No Replies

iframe access using perl

access iframe data using perl

         

sumitmishra

11:10 pm on Nov 15, 2006 (gmt 0)

10+ Year Member



I am using perl to create an iframe that asks for user to click on one of two button ('agree', 'deny').

The result of this is returned by the server as values set as URL fragment, example:

[host...] or [host...]

From my perl script how do I access this information to figure out what button the user has clicked?

Below is the part of the perl code that creates the iframe:
*****************************************************
print "Content-type: text/html\n\n";
print <<"EOF";
<html>
<body>
<p> You must first grant hostname to READ your data </p>
<br>
<iframe src="$finalRedirectURL" width="60%" height="50%" name="Consent Form" scrolling=no></iframe>
</body>
</html>
*****************************************************************

the src="$finalRedirectURL", is the url of the server that is throwing the page with agree/deny option and throwing result as part of URL

MichaelBluejay

1:40 am on Nov 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's the form code itself that's important (the code that makes up the iframe). You use a parameter to tell the form where to send the data, e.g.:

<form ACTION=submitform.pl METHOD=post>

or

<form ACTION=submitform.pl METHOD=get>

With "post" then the form data is passed invisibly to your script. With "get" the form data is passed through the url (e.g., [domain.com?submit=accept)....] Both have their advantages and disadvantages, but "post" is a lot more common.

If you don't have an "action" parameter in your <form>, then you're never actually sending the form back to the server.

perl_diver

3:13 am on Nov 16, 2006 (gmt 0)

10+ Year Member



You could use an image:

<a href="$finalRedirectURL"><img src="button.gif" border="0"></a>

or a form:

<form action="yourscript.pl" method="post">
<input type="hidden" value="agree">
<input type="submit" value="Agree">
</form>

sumitmishra

4:28 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



acually, the form code is coming from a server which is not in my control. So, its not really me sending the data to the server, but the form code in the iframe (which is controlled by the server).

I am using the functionality provided by this server, by including its server provided redirect url in an iframe, and the server is throwing back the response to me in an URL fragment (as I had mentioned earlier). My issue is that I dont know how to access this URL fragment from my perl code (I do see on my browser address window the response url 'http://<host>/#*$!.cgi#RESPONSE')

perl_diver

6:16 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



then lets see your perl code.

sumitmishra

9:20 pm on Nov 16, 2006 (gmt 0)

10+ Year Member



Thanks to everyone for posting replies to my query.
I was able to solve my problem by using javascript inside my perl script.

I used javascript to check for the URL fragment, and according to the response given by the server in the URL fragment, my code branches accordingly:
in the perl script.....
print <<"EOF";
<html>
<head>
<script type="text/javascript" language="JavaScript">
var lastId = "";
function checkForMessages(){
if(location.hash!= lastId){
lastId = location.hash;
document.getElementById("output").innerHTML = lastId;
if (lastId == "#CONSENTDONE") {
setTimeout('goRedirect()',1000);
}
else {
setTimeout('goBack()',1000);
}

}
}
setInterval(checkForMessages, 200);