Page 1 of 2
How to refresh page without click refresh button?
Posted: Tue May 25, 2004 12:02 pm
by loongest
i need some help in php coding...
the problem i desire to solve is after i purchase and add cart...
the cart contain in main page will need refresh once..
how can i do it without using refresh button ?
thanks
Posted: Tue May 25, 2004 12:05 pm
by feyd
there's
Code: Select all
<meta http-equiv=refresh content="5; url=http://blah.com">
and
<script language="javascript">document.location.href = "http://blah.com";</script>
there are others, but those are the basics..
Posted: Tue May 25, 2004 12:15 pm
by loongest
I'd like to thanks for comment feyd!
but i'm not very understand the statement ... :p
can u brief explain to me
<meta http-equiv=refresh content="5; url=
http://blah.com">
and
<script language="javascript">document.location.href = "http://blah.com";</script>
Posted: Tue May 25, 2004 12:19 pm
by evilMind
in php;
Code: Select all
header('Refresh: 7200'); // refresh every 2 hours
Posted: Tue May 25, 2004 12:24 pm
by loongest
i'm using pop up window to display new item with purchase
so how do i code in php if i click close pop up window and the mainpage get refresh ?
Posted: Tue May 25, 2004 12:27 pm
by feyd
<meta http-equiv=refresh content="5; url=http://blah.com">
normally goes in a page's header.. like this
Code: Select all
<html>
<head>
<!-- meta tags go in here -->
</head>
<body>
content appears here
</body>
</html>
the 'content' attribute contains 1 or more things. A timeout in seconds (in this case, 5 seconds), and an optional url value of where to redirect to. if the optional url is desired, a semicolon and 'url=' should appear after the timeout value. If the optional url is left out, the page will refresh itself at the specified time.
<script language="javascript">document.location.href = "http://blah.com";</script>
this can be placed pretty much anywhere in the html, however, the page will redirect to the specified address immediately when it's hit. If you wish to delay the time, like how the meta refresh works:
Code: Select all
<script language="javascript">setTimeout('document.location.href = "http://blah.com";',5000);</script>
this will also get called in 5 seconds, note that the time, is in milliseconds, not seconds.
Posted: Tue May 25, 2004 12:39 pm
by loongest
i'm using pop up window to display new item with purchase
so how do i code in php if i click close pop up window and the mainpage get refresh ?
Posted: Tue May 25, 2004 12:43 pm
by feyd
in the popup, use
Code: Select all
onunload="window.opener.location.href = window.opener.location.href"
or similar
edit: oops.. that should be onunload.
Posted: Tue May 25, 2004 12:45 pm
by loongest
er..... where should i put this statement ?
Posted: Tue May 25, 2004 12:49 pm
by feyd
<body onunload="">
Posted: Tue May 25, 2004 1:12 pm
by loongest
onunload="window.opener.location.href = window.opener.location.href"
this statement means when the window is unload and ?? can u explain me the remain statement means ?
Posted: Tue May 25, 2004 1:28 pm
by feyd
when the window is closed, the code will be run.. the code tells the popup's creator to reload itself.
Posted: Tue May 25, 2004 1:41 pm
by loongest
so i add the statement on my pop up html with following code
<body onunload="onunload="window.opener.location.href = window.opener.location.href">
after i close the popup my mainpage will get refresh ? or just the popup page will get refresh on next time ?
Posted: Tue May 25, 2004 1:43 pm
by evilMind
<body onunload="window.opener.location.href = window.opener.location.href">
and as long as the main page used window.open the main page will get refreshed when the user closes the popup window
Posted: Tue May 25, 2004 1:43 pm
by feyd
more like
Code: Select all
<body onunload="window.opener.location.href = window.opener.location.href">
your main page, the page that created the popup, will get refreshed, or at least should.. you may need to fake it out a little bit.. as some browsers may not really refresh, since it's telling it to load the same page..