/    Sign up×
Community /Pin to ProfileBookmark

Changing the page the browser refreshes to

This might sound like an odd question, but is there any way to change the url that a page refreshes to? This is my situation:

[FONT=”Courier New”]page.php[/FONT] can be loaded as either [FONT=”Courier New”]page.php[/FONT] or with one GET variable, [FONT=”Courier New”]page.php?foo=bar[/FONT]. When it is loaded with the variable, certain one-time actions are performed (nothing to do with altering anything server-side ? ). The problem is, if the user refreshes with the query string (which might happen often based on the content of the page), various problems occur.

My question is simple: Is there a way to make it so [FONT=”Courier New”]page.php[/FONT] will ALWAYS refresh/reload to [FONT=”Courier New”]page.php[/FONT], without any query string? Is there some sort of onrefresh or onreload event hander? Thanks in advance.

[COLOR=”White”].[/COLOR]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@mathursrishtiJul 22.2008 — There is no event like "onrefresh" or "onreload". But, we can let our page know that it is first time post or refreshed page.

Add a hidden field to your page, set the value of the field when it is called.

On every page load check the value of the hidden field, if the value for hidden field is set or not null then this is "refreshed" and if the filed is blank then this is first time post.
Copy linkTweet thisAlerts:
@shane_carrauthorJul 23.2008 — Thanks for the response. That's not exactly what I was looking for, though it would be a pretty good method ? Wouldn't it partly depend upon whether the browser "refills" the fields on page refreshes? I'm not sure what the standard is with browser behavior in that situation.

I found a way to check via PHP, which seems to be reliable.

Thanks for your inspiration, as it helped me think of the PHP method (which checks a value in a database that would have been changed by the first load).


[COLOR="White"].[/COLOR]
Copy linkTweet thisAlerts:
@cgishackJul 23.2008 — why use a database for this?

look into reading a php session variable.

this might be a better method.
Copy linkTweet thisAlerts:
@shane_carrauthorJul 26.2008 — why use a database for this?

look into reading a php session variable.

this might be a better method.[/QUOTE]


I [I]could[/I] use a session variable for this, but one of the things that the "query code" does is change a certain value in a database. So, I thought that would be a good place to check ?
×

Success!

Help @shane_carr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...