i need a java script to rotate the start page so that each visitor is taken to a new page each time they visit.ie if someone visits my page they will be taken to another page which i can set and if they hit reload they will be taken to next page in the list.
Need this script
I don't know how to do it in JavaScript, but in PHP you just could create an array of URLs, choose one randomly and forward the browser to it easily. I can write an example if you want.
| vignesh_natraj wrote: |
| i need a java script to rotate the start page so that each visitor is taken to a new page each time they visit.ie if someone visits my page they will be taken to another page which i can set and if they hit reload they will be taken to next page in the list. |
Make an array with the url's.
if(a cookie is already set){
set cookie to cookie + 1
} else {
set a cookie with value 0
}
location.href = urlArray[cookieValue];
| Ducksteina wrote: |
| I don't know how to do it in JavaScript, but in PHP you just could create an array of URLs, choose one randomly and forward the browser to it easily. I can write an example if you want. |
i actually tried javascript usind arays but it didn't work out so can you give an example in php
PHP, with same functionality with the Javascript code above:
| Code: |
|
if(isset($_COOKIE['name'])) { setcookie("name", "1", <unix timestamp>); } else { setcookie("name", "0", <unix timestamp>); } header("Location: $url_array[cookie_vals]"); |
