• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

I need a Javascript or PHP script...

LeetViet

Platinum Member
I need a Javascript or PHP script that displays a page for 10 seconds when a link is clicked then redirects to the whatever destination.

I only want it to happen once per day, are there any FREE scripts that does this?
 
<form name="redirect">
<center>
<font face="Arial">
<b>You will be redirected to the script in<br>
<br>
<form><input type="text" size="3" name="redirect2">
</form>seconds</b>
</font>
</center>
<script><!--

var targetURL="NEWURLHERE"

var countdownfrom=10

var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
window.location=targetURL
return
}
setTimeout("countredirect()",1000)
}

countredirect()
</script>
 
minendo is always free 😉

*puts mindendo down on friends list for later help for sure lol
 
I need this for any link that is clicked, not just pages where I have to put the target URL. Got one like that minendo?
 
I could tell you how to pull this off using only minendo's code, but I've seen spyware do something like this and it pisses me off to no end, so I will not post it.
 
Originally posted by: LeetViet
I need this for any link that is clicked, not just pages where I have to put the target URL. Got one like that minendo?

There are many ways... one simple on is make that page for the index page and then delete all the files on the site, so any link would give a 404. Then log into your hosts control panel and make the 404 error page have the redirect script.

Now any "page " will redirect to the new one.
 
wow minendo, you could replace your 15 lines of code with one meta tag....

meta redirect, or refresh, one of them..

edit: just put this in the head section of the page

<meta http-equiv="refresh" content="10;url=urlhere">
 
i was thinking meta refresh too... and then the "when a link is clicked" confused me... when exactly is this link clicked ? Just before they hit the page that will be doing the redirect ? Or while they're on the page doing the redirect ?
 
Originally posted by: WannaFly
wow minendo, you could replace your 15 lines of code with one meta tag....

meta redirect, or refresh, one of them..

edit: just put this in the head section of the page

<meta http-equiv="refresh" content="10;url=urlhere">

I don't want a Meta redirect. I need this on ANY link that is clicked and for the script to only do this once per day.

Before they hit the page or while going to the target.
 
If I understood you correctly--this is what you had in mind? Link
I went php since i'm a java noob.

You'll have to send all your links through the php page.
The urls are checked against an existing array (via cookie) and are appended to the array if it isn't found.
I have the cookie set to expire in 1 min. But you can change it to expire in 1 day.

Of course I may be wrong and don't really know what the hell you want. 😉
 
Originally posted by: CaseTragedy
If I understood you correctly--this is what you had in mind? Link
I went php since i'm a java noob.

You'll have to send all your links through the php page.
The urls are checked against an existing array (via cookie) and are appended to the array if it isn't found.
I have the cookie set to expire in 1 min. But you can change it to expire in 1 day.

Of course I may be wrong and don't really know what the hell you want. 😉

Very similar.

Think this will work on my site? (below) I don't want to have to write in every single target...
 
You're gonna need to use server and client side scripting. The easiest way would probably be to use the url rewrite engine of apache to redirect all urls to something like redirect.php?page=blah, redirect.php would check a cookie, if the page hasn't been served today, set a cookie and output the page you want to display with a meta tag or some javascript set to refresh to blah in 10 seconds. This way wouldn't require you to change any of the pages you already have. The better way would be to call a function at the top of all your pages(php) that would handle checking/setting of cookies, and appropriate output. Depending on how many pages your site is, using the rewrite engine might be more practical, though a bit slower. You don't need to use php for any of this, any server side scripting language will do. I don't know of any ready made scripts to accomplish what you want, it really shouldn't be too tough to pull off yourself though.
 
Originally posted by: Templeton
You're gonna need to use server and client side scripting. The easiest way would probably be to use the url rewrite engine of apache to redirect all urls to something like redirect.php?page=blah, redirect.php would check a cookie, if the page hasn't been served today, set a cookie and output the page you want to display with a meta tag or some javascript set to refresh to blah in 10 seconds. This way wouldn't require you to change any of the pages you already have. The better way would be to call a function at the top of all your pages(php) that would handle checking/setting of cookies, and appropriate output. Depending on how many pages your site is, using the rewrite engine might be more practical, though a bit slower. You don't need to use php for any of this, any server side scripting language will do. I don't know of any ready made scripts to accomplish what you want, it really shouldn't be too tough to pull off yourself though.

😕
 
Originally posted by: LeetViet
Originally posted by: DeviousTrap
Originally posted by: CaseTragedy
You mean you want every existing link to be redirected without changing the links themselves?

Correct 🙂

Then whats wrong with my idea?

My forums will not work without an index.php and I don't want to rewrite everything to index2.php or something.

Can you explain what kind of site you are redirecting and to where?

All you do is you set up a index.php with the same redirect script as the 404 page. You would have both.
 
Originally posted by: minendo
<form name="redirect">
<center>
<font face="Arial">
<b>You will be redirected to the script in<br>
<br>
<form><input type="text" size="3" name="redirect2">
</form>seconds</b>
</font>
</center>
<script><!--

var targetURL="NEWURLHERE"

var countdownfrom=10

var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if (currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
window.location=targetURL
return
}
setTimeout("countredirect()",1000)
}

countredirect()
</script>

You're missing an opening parenthesis on your if statement. Fixed in the quote above.
 
Back
Top