views:

246

answers:

1

I have a feedback pop up (TickBox) that loads a cross domain iFrame and when submitting the form it loads the "thanks for...." page.

I want that when user submits the feedback button it should hide the iFrame wrapper.

I know that because of the "same origin policy" security limitations you cant get the actual location of the iFrame when it changes.

My question is, can i somehow get the history via history.length to check if this is a new location?

Or maybe read its content and find the new page text (like: "thanks for") and hide its wrapper

$("iframe").load(function(){
    var iframeSrc = $(this).contents()[0].location.hash; /*or history.length */
    var isSubmitedUrl = /Home_Landing/
    var testUrl = iframeSrc.search(isSubmitedUrl)

  if(testUrl >= 0){    /*or if(history.length >= 0)*/
    $(".iframeWrap").hide();
  }

 })
+2  A: 

The Same origin policy not only restricts access to the iframe location but the entire window object for that iframe.

So if you can't get to the iframe's window, you can't get to the iframe's window.history property.

You cannot even read the src property on the iframe in your own document, as it does not reflect the changes in the location of the iframe.

The best I can think of is to pass the iframe's url through a proxy on your own server, in which case you'd be able to at least access it's DOM and listen for "onsubmit" of the embedded form, to hide your wrapper.

Roatin Marth
Thanks much, can you please say a few more words, (or post a link) to explain a bit more the solution of passing iframe's url proxy on own server
adardesign
@Eliazer: what server-side technology are you using? php, asp.net etc.
Roatin Marth
in this project i am using asp.net
adardesign
@Eliazer Braun: here's how to do it in asp.net: https://msmvps.com/blogs/omar/archive/2008/04/14/fast-streaming-ajax-proxy-continuously-download-from-cross-domain.aspx
Roatin Marth