Detect cross-domain content with iframe

Asked 2 years ago, Updated 2 years ago, 109 views

Hello!

I'd like to ask you about the iframe cross domain

Currently, iframe imports the authentication web in the external domain.

Once you complete your authentication, you will be redirected to an empty page.

I'd like to catch this redirect and process it as a callback on my main page (it's different from the external domain that I have authentication with).

When I looked at the src of iframe, the src didn't change even if I redirected it.

Also, I know that if you try to get or see the contents of iframe through JavaScript, it gets stuck in cross domain, and it actually got stuck when I tried it.

Is it because of the cross domain that the src of iframe does not change in real time?

Also, I would like to know if there is any way to catch and process it as a callback on the website when it is redirected from the external domain of the iframe!

iframe javascript

2022-09-22 21:42

1 Answers

Basically, importing content in the iframe for external domains would have been prevented for security reasons. Wouldn't it be possible if there is no permission setting for cross-domain?

To detect changes in the content of the iframe, do the following:

$("iframe").load(function(){
    // Called when this iframe imports content, refreshes, page changes, etc.
});

In HTML5, the iframe between cross-domain and the communication method between parents is done through a function called postMessage.


2022-09-22 21:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.