最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reload html element - Stack Overflow

programmeradmin4浏览0评论

I have a page which opens another page using window.open and does some work and refreshes whole parent page . Is it possible to refresh content of a div/table on parent page using JQuery/Javascript ?

FYI : Here the content of the div is not changing there is an image inside div which is edited by child window which I want to update but that image does not have unique id so I want to refresh whole div .

Thanks.

I have a page which opens another page using window.open and does some work and refreshes whole parent page . Is it possible to refresh content of a div/table on parent page using JQuery/Javascript ?

FYI : Here the content of the div is not changing there is an image inside div which is edited by child window which I want to update but that image does not have unique id so I want to refresh whole div .

Thanks.

Share Improve this question asked Apr 4, 2011 at 17:05 Pit DiggerPit Digger 9,80023 gold badges81 silver badges125 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

Pure JavaScript (not JQuery) solution : wrap your div in an iframe, give it an id myFrame, then refresh it from the child like this:

parent.document.getElementById("myFrame").reload();

You can use the .load() method of jQuery to quickly update the contents of a container

http://api.jquery./load

Simple as

$('#result').load('ajax/test.html', function() {
  alert('Load was performed.');
});
$("#myDiv", window.parent.document).load("page.html", function(){
    alert("Portion of page loaded");
});

The second parameter of $() is the context to search into. Default to document.

You can use .html() instead of .load() if you want reload from html string instead of using another page.

发布评论

评论列表(0)

  1. 暂无评论