How do i refresh an iframe




















Yi Jiang Actually, this approach didn't work for me in Chrome. There was no 'contentWindow' property. Though it was possible to use document. MikeBevz can location. If you can't access iframe window, you have to change src attribute of iframe tag.

Show 8 more comments. And what exactly do you do if the iframe's source has changed since it was added to the page? Works for me on Chrome ver33! Strange that we can't simply use reload but this is allowed. Note that if the iframe src has a hash in it e. I've used the approach of adding a throwaway query parameter like? This causes the iframe to scroll back to the top. Show 2 more comments. Yahel Please note to any future people that this and the plain js solution are the best to use, as it's cross platform and works across domains.

Add empty space also reload the iFrame automatically. Yohanim Yohanim 2, 6 6 gold badges 47 47 silver badges 77 77 bronze badges. This is the best answer because it works on all iframes, including cross-origin iframes. In contrast, the contentWindow. But the latter doesn't scroll to the top, so it depends on your priorities.

Liam M Liam M 5, 2 2 gold badges 38 38 silver badges 52 52 bronze badges. Patrick Rudolph Patrick Rudolph 2, 16 16 silver badges 30 30 bronze badges. I've just tested the same approach but without setTimeout - and it worked for me.

A refinement on yajra's post I like the thought, but hate the idea of browser detection. Worked for me in IE8, Firefox Aaron Wallentine Aaron Wallentine 2, 18 18 silver badges 20 20 bronze badges.

Another solution. A disadvantage of that is modifies the root document DOM tree and will cause a repaint. Northern Northern 1, 1 1 gold badge 15 15 silver badges 19 19 bronze badges.

K 1, 2 2 gold badges 18 18 silver badges 34 34 bronze badges. Shaulian Shaulian 5 5 silver badges 8 8 bronze badges. If you using Jquery then there is one line code. Paresh Paresh 8 8 silver badges 21 21 bronze badges. If all of the above doesn't work for you: window. Or I don't understand this fully and talk gibberish, anyways this worked for me like a charm :. Marcin Janeczek Marcin Janeczek 33 1 1 silver badge 5 5 bronze badges. Have you considered appending to the url a meaningless query string parameter?

Tharabas 3, 1 1 gold badge 27 27 silver badges 28 28 bronze badges. Sid Sid 1 1 1 bronze badge. Not the choice I would use but I guess it would do.

With some additional code that you could have added in. Community Bot 1 1 1 silver badge. Todd Todd 2 2 silver badges 11 11 bronze badges. Using self. Vivek Kumar Vivek Kumar 1, 2 2 gold badges 16 16 silver badges 25 25 bronze badges. Reload from inside Iframe If your app is inside an Iframe you can refresh it with replacing the location href: document.

Andrii Verbytskyi Andrii Verbytskyi 5, 2 2 gold badges 41 41 silver badges 36 36 bronze badges. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile.

Linked 0. See more linked questions. Related Change Language. Related Articles. Table of Contents. Save Article. Improve Article. Like Article. Previous How to place a div inside an iframe for IE?

Next How to check a webpage is loaded inside an iframe or into the browser window using JavaScript? Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Load Comments. What's New.



0コメント

  • 1000 / 1000