How to force an iFrame to reload once it loads

前端 未结 4 853
夕颜
夕颜 2021-01-01 04:43

I have numerous iframes that load specific content on my pages. Both the parent and iframe are on the same domain.

I have a scrollbar inside the iframe that doesn\'

4条回答
  •  我在风中等你
    2021-01-01 05:00

    Here's a complete solution to the original question:

    
    
    

    The updated question is not really clear (what's "the link to the iFrame" and where is it in your snippet?), but you have a few issues with the code:

    • "calling this JS from the body with onLoad", assuming you mean an iframe's body, means the variable you're hoping to use to avoid infinite reloading will get clobbered along with the rest of the iframe's page when it's reloaded. You need to either load a slightly different URL in the iframe (and check the URL on iframe's onload before reloading) or put the flag variable in the outer page (and access it with parent.variableName - that should work I think)
    • if (pl=1) { should use ==, as = is always an assignment.
    • change+pl; has no effect.

提交回复
热议问题