Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to know when the page fetching is done? #8

Closed
sangdth opened this issue Feb 1, 2019 · 11 comments
Closed

Is there any way to know when the page fetching is done? #8

sangdth opened this issue Feb 1, 2019 · 11 comments

Comments

@sangdth
Copy link

sangdth commented Feb 1, 2019

It could be great if we could have something like this:

<vue-friendly-iframe
    :src="path/to/external.com"
    @finish="handleLoading"
/>

methods: {
    handleLoading() {
        console.log('External link loaded. Do something');
    }
}
@sangdth sangdth changed the title Is there any way to know the page fetching is done? Is there any way to know when the page fetching is done? Feb 1, 2019
@officert
Copy link
Owner

officert commented Feb 6, 2019

Added a load event when the iframe loads:

https://github.com/officert/vue-friendly-iframe/releases/tag/0.11.0

<vue-friendly-iframe :src="iframeSrc" @load="onLoad"></vue-friendly-iframe>

@officert officert closed this as completed Feb 6, 2019
@sangdth
Copy link
Author

sangdth commented Feb 6, 2019

Sorry, maybe I misunderstood or something. I have checked the code and tried the @load but it seems to check only when the iframe loaded, not the content of iframe (link to the site) is loaded completely.

On my side, the onLoad get triggered way too fast, because my client use Wordpress as external links, and it takes more than 3 seconds to complete the loading.

@officert
Copy link
Owner

officert commented Feb 6, 2019

Hmm yea the load event is trigger using the iframe's onload method. I don't believe there's a way to tell if an iframe's content has fully loaded. Not without something in the iframe message the outer page that it has finished loading, which isn't possibly with a library like this where we don't control the inner page.

@officert officert reopened this Feb 6, 2019
@sangdth
Copy link
Author

sangdth commented Feb 9, 2019

@officert
Copy link
Owner

officert commented Feb 10, 2019

Yea those events work if you have access to the page inside the iframe, but you can't access those events from outside the iframe as far I know.

@officert
Copy link
Owner

@officert
Copy link
Owner

Found a way to inject a script into the inner document and listen for the readstatechange event : https://github.com/officert/vue-friendly-iframe/releases/tag/0.12.0

updated in V0.12.0

@sangdth
Copy link
Author

sangdth commented Feb 10, 2019

love you! ;D

@sangdth sangdth closed this as completed Feb 10, 2019
@officert
Copy link
Owner

Let me know if this is working properly for you. I'm still not sure it actually works, as I'm seeing the readstatechange event fire before the iframe load event fires.

@officert
Copy link
Owner

I think it's because I'm simply writing some HTML and JS into the document here
https://github.com/officert/vue-friendly-iframe/blob/master/src/components/FriendlyIframe/index.vue#L51
so we're seeing the onreadystatechange event fired when this document loads. But then the onload of the body fires and changes the URL. I don't think we're getting the onreadystatechange from the actually page being loaded into the iframe.

@sangdth
Copy link
Author

sangdth commented Feb 10, 2019

I have done a quick test and it came like this:

document-load fired at 1549833977121
load fired at          1549833977122
iframe-load fired at   1549833977125

So I think as you said before, we do not have any message from inside the source to tell us about the event. Maybe in the future, we will have something, but I'm good to go with this version.

Thanks for your time and effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants