0

I have an MVC application that loads a video content package (from an external third-party vendor) into an iFrame. Under normal circumstances, when you make the call to this third party to retrieve the content, you pass it a ReturnURL parameter that tells the vendor's player where to redirect after the video content module has completed. Unfortunately, some new updated packages do not support the redirect. Instead of redirecting to the designated Redirect URL, upon the content module completing, it just redirects the iFrame to a page called "goodbye.htm" (which is still on the same domain as the third-party vendor).

Per recommendation, the vendor suggested we have a listener on the iFrame to detect when the iFrame src changes to this "goodbye.htm" page and then execute the code we need to redirect.

One of the problems we've encountered is getting the src of the iFrame AFTER it changes. Obviously just getting the src attribute from the iFrame only returns the original src, even after it changes. The other issue of course is that the domain of the goodbye.htm page is different than the domain of our application and the parent window, so it violates Same-Origin Policy.

Below is our JQuery function we're using to attempt the redirect.

$('.js__iframe-play').on('load', function () {
    var src = $(this).attr("src");
    if (src.includes("goodbye.htm")) {
    const url = "/Learn/GetResults/" + $(this).data("class-id") + "?regid=" + $(this).data("registration-id");
    console.log(url);
    const newiframe = $(this).clone();
    newiframe.attr("src", url);
    $(this).after(newiframe);
    $(this).remove();
    }
})

Does anyone have any idea of how we can accomplish our goal?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Ryan
  • 101
  • 9
  • Review [the difference between `prop` and `attr`](https://stackoverflow.com/questions/5874652/prop-vs-attr). – Heretic Monkey Apr 24 '19 at 16:49
  • @HereticMonkey even when using prop instead of attr, it only grabs the original src of the iFrame, the src variable does not update when the iFrame src changes. – Ryan Apr 24 '19 at 17:02
  • The `src` variable is not a reference to the the `src` property of the iframe element. It is the value of that property at the time you called `attr` (or `prop`). You might want to try using `this.src` to eliminate jQuery altogether. – Heretic Monkey Apr 24 '19 at 17:05

0 Answers0