Solved

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

Posted on 2010-08-22
7
2,890 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now