Link to home
Start Free TrialLog in
Avatar of tekkieguru
tekkieguruFlag for United States of America

asked on

Is there any way to use Javascript to do a Ctrl-F5 refresh?

I have a small php file that runs inside of a frame. Is there any way that i can do a CTRL-F5 type of refresh and reload the whole browser window. I've tried parent.location.reload(true), location.reload(), and quite a few others. The page doesnt seem to want to redirect. If i do a CTRL-F5 on my keyboard it reloads fine. Any help is much appreciated.
$SiteLink = "/home/wwwnhs/public_html/userfiles/image/";
if (isset($_GET['file']))
{
	$sDeleteFileName = $_GET['file'];
	$sDeleteFileName = $SiteLink.$sDeleteFileName;
	if (file_exists($sDeleteFileName)) {
			unlink($sDeleteFileName);
			/*********************************
			* Need Reload Function HERE!!!!! *
			*********************************/

			//echo "<br />File ".$sDeleteFileName. " Exists!";
	}
	else {
		echo "<br />File - ".$sDeleteFileName." Does not Exist!";	
	}
}
else {
	echo "<br />File Variable Not Set!!!!";
}

Open in new window

Avatar of Snarfles
Snarfles
Flag of Australia image

Avatar of Dave Baldwin
You can't do a Refresh function in PHP because it runs on the server and it's done running by the time you see the page.  Does the PHP create a full web page inside the iframe?  If it does, you could do a periodic refresh with a 'meta' tag.  Then you'd have to rewrite the tag every time with a slightly different query string to make sure it isn't just reloaded from cache.
Opps, seems I didn't read your question correctly. you're in a  iframe...

You could output something like this

top.window.location.reload();
That needs to be in javascript tags

<script type="text/javascript">
top.window.location.reload();
</script>
In the frame, do a javascript:

window.parent.location.href='http://google.com';

you can do this even in a onclick="" event if you want, or just <script>window.parent.location.href='http://google.ro';</script> to refresh as soon as it's loaded
ASKER CERTIFIED SOLUTION
Avatar of hexer4u
hexer4u
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
top.location.reload(1); // reload from server