0

I am using an html form to submit information to a specific URL that is loaded in an iframe on one of my website pages on my domain. One of the html form inputs is a URL that will be posted in the iframed page when I submit the form. But when I click on the link (the one which I have specified the URL for in the html form), I need it to break out of the iframe, and load in the parent window (the window which the iframe is currently in). This is my form, and you can see the input for the "producturl"...that is where I am having trouble...

<form action="http://ww#.aitsafe.com/cf/add.cfm" method="post"> 
<input type="hidden" name="userid" value="#######">
<input type="hidden" name="nocart"> 
<input type="hidden" name="return" value="www.fruitfulfarm.net/cart_2.html"> 
<input type="hidden" name="producturl" value=<a href="www.fruitfulfarm.net" target="_top"</a>
<input type="hidden" name="product" value="Product">
<input type="hidden" name="price" value="49.95">
<input class="rounded" type="submit" name="Submit" value="Add To Cart">
</form>

Can someone show me a way to get the URL to break out of the iframe by using a certain target/value code in the "producturl" syntax?

AaronH
  • 47
  • 3
  • 9
  • target should be _parent if it is in a frame – Loris Jan 08 '13 at 20:19
  • still doesn't break out of the iframe though, it also has an error when you click on the link in the iframe that says: Not Found - The requested URL /cf/www.fruitfulfarm.net was not found on this server. I don't know why this is.? – AaronH Jan 08 '13 at 20:36
  • This is not well-formatted html. Line 5 is not comprehensible. – Loris Jan 08 '13 at 20:47
  • what needs to be changed to make it formatted correctly? I was experimenting with line 5. – AaronH Jan 08 '13 at 21:27
  • I think it is possible with javascript. As I may assume your iframe does some server side tricks. So you can just pass url of page that you want to redirect to (without a href etc.) and reload using javascript (smth. like window.top.location.href). – Sergiy T. Jan 08 '13 at 21:46
  • I don't think ww#.aitsafe.com will work either. Perhaps you mean www.aitsafe.com? – Sterling Bourne Mar 28 '13 at 14:29

1 Answers1

0

I would use some JavasScript.

this.top.location = "www.fruitfulfarm.net";

Have a look at css-tricks.

Kenny Linsky
  • 1,726
  • 3
  • 17
  • 41
Dave Gill
  • 234
  • 1
  • 14
  • How do I implement this? what do I put in the form input? and what do I need to do with coding the iframe? Please give a little bit of specifics, as I am not fluent in coding. – AaronH Jan 08 '13 at 22:06
  • Try adding some javascript at the top of your page 'code'var link = document.getElementById('my-link'); link.onclick = function() { this.top.lcation = link.href return false; } – Dave Gill Jan 09 '13 at 17:26
  • Did you use what I suggested? Or did you do it some other way? – Dave Gill Jan 09 '13 at 21:34
  • You have to put this code if (top != parent) { top.location.href = parent.location.href; } in a new javascript file, name it something like breakiframe.js and upload in to your server, then refer to it in the head of your webpage using Hope someone else finds this usefull! – AaronH Jan 10 '13 at 01:23