I am using menu type and that respective content load in iframe with same domain url. When click the div(using class name) inside the iframe content i need to reload the url.
I tried the following code.
Html Code:
<ul>
<li href="http://mywebsite/contact">contact</li>
<li href="http://mywebsite/faq">faq</li>
<li href="http://mywebsite/abcd">abcd</li>
</ul>
<iframe class="embed-responsive-item" src="http://mywebsite/contact" id="right_content_iframe" scrolling="no" frameborder="0" style="width:100%;border:0px;min-height:500px;" ></iframe>
Js Code:
$(document).ready(function() {
$('ul.li').click(function(e) {
e.preventDefault();
if ($(this).attr('href')) {
console.log($(this).attr('href'));
$('#right_content_iframe').attr('src', $(this).attr('href'));
e.preventDefault();
}
});
var iframe = $('#right_content_iframe').contents();
console.log(iframe);
iframe.find(".page_refresh").click(function() {
location.reload();
});
});
The default contact page will load in iframe. When i click the faq link the iframe url load http://mywebsite/faq. On that time when i click the div (.page_refres) in faq page I need to reload the url.
Faq Page:
<div>Same text</div>
<div class="page_refresh" > Page Refresh</div>