javascript - Refresh iframe when screen is clicked -
not familiar javascript. have done searching , having trouble implementing code current project.
basically want refresh iframe when screen clicked. have code:
document.getelementbyid('').contentwindow.location.reload(true);
i want integrate code:
$(".launch").loadthis({ direction: "left", connect: true });
how go this?
there issues unclear in question.
1) mean when "screen clicked" ?
- anywhere in open browser window?
- anywhere in open browser window including iframe?
2) iframe 100% of width , height of browser window?
regardless, below break down problem , give solution...
how refresh webpage?
you can refresh webpage using:
location.reload(true);
how refresh iframe?
you may refresh iframe using code here: refresh iframe
<iframe id="myiframe" src="http://google.com"></iframe> document.getelementbyid("myiframe").src = "http://www.google.com?"+(+new date());
how detect click?
you can use solution here: https://stackoverflow.com/a/2622026/1688441
document.onclick= function(event) { // compensate ie<9's non-standard event model // if (event===undefined) event= window.event; var target= 'target' in event? event.target : event.srcelement; alert('clicked on '+target.tagname); };
remaining issues:
what happens if user clicks within iframe?
if user clicks within iframe, , control code of iframe can have click listener within html/javascript of iframe , trigger refresh.
if have different domains, due security reasons there not can done.
Comments
Post a Comment