...

View Full Version : Just need a little extra to make this iframe refresh just once...



eabigelow
09-13-2011, 11:32 PM
Hi--

I have found a neat trick to refresh an iframe in an html page, but I just need one little twist to make it work just right. I would like to make the iframe content refresh just once, not matter how many times the link is clicked...

Right now, I have this in the head:
<script type="text/javascript">
function refreshIframe(el) {
var f = document.getElementById(el)
var rsrc = f.src
f.src="about:blank"
f.src=rsrc
}
</script>

And this is the link which, when clicked, refreshes the iframe every time it is clicked:
<a href="#page_7c" onclick="refreshIframe('test'); return false">

"test" is the id of the iframe.

I am sure how to do this is really simple, but it escapes me... Many thanks!

xelawho
09-13-2011, 11:38 PM
here's a cheap and nasty way to do it...



var a=0;
function refreshIframe(el) {
if(a==0){
var f = document.getElementById(el)
var rsrc = f.src
f.src="about:blank"
f.src=rsrc
}
a=1;
}

eabigelow
09-14-2011, 02:02 AM
Works like a charm. Many thanks!!!!

Logic Ali
09-14-2011, 02:51 AM
Self-cancelling handler:
<a href="#page_7c" onclick="refreshIframe('test'); this.onclick = function(){ return false; }; return false">

eabigelow
09-14-2011, 03:09 AM
This also does the trick. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum