Solved

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

Posted on 2010-08-22
7
2,992 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:tekkieguru
7 Comments
 
LVL 9

Expert Comment

by:Snarfles
ID: 33498259
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33498322
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.
0
 
LVL 9

Expert Comment

by:Snarfles
ID: 33498398
Opps, seems I didn't read your question correctly. you're in a  iframe...

You could output something like this

top.window.location.reload();
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 9

Expert Comment

by:Snarfles
ID: 33498400
That needs to be in javascript tags

<script type="text/javascript">
top.window.location.reload();
</script>
0
 
LVL 6

Expert Comment

by:hexer4u
ID: 33499427
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
0
 
LVL 6

Accepted Solution

by:
hexer4u earned 500 total points
ID: 33499437
forgot this.

replace
/*********************************
* Need Reload Function HERE!!!!! *
*********************************/

with
echo "
<script type='text/javascript'>
window.parent.location.href='http://THE_URL_YOU_WANT';
</script>
";

and the page will refresh automatically.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33500296
top.location.reload(1); // reload from server
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question