Solved

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

Posted on 2010-08-22
7
2,780 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
Comment Utility
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:Snarfles
Comment Utility
That needs to be in javascript tags

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

Expert Comment

by:hexer4u
Comment Utility
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
Comment Utility
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
Comment Utility
top.location.reload(1); // reload from server
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.

771 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

16 Experts available now in Live!

Get 1:1 Help Now