Question:
Need to get different content whenever the browser get refreshed using javascript?
ranjani s
2008-11-17 05:44:37 UTC
I need the javascript to change the content whenever the page get refreshed.

Thanks in advance
Ranjani S
Three answers:
richarduie
2008-11-17 16:07:18 UTC
There are a couple of trivial solutions. One is to have a bunch of different pages that all know about each other and either randomly or according to some scheme elect among the set for each reload event. Another would be to include an array of page contents for all the different versions of the page you want to display; again an in-page script process would need to determine onload which content to reveal.



A less trivial, but I think more satisfactory, solution is to allow a script to determine the file from which to fetch the content at each page load. The following example applies an AJAX process to fetch randomly selected alternative files and insert the contents into the page. The content files div0.div, div1.div, and any other are left to your imagination. Read the code - read the comments....ask questions, if you need help.























?
2008-11-17 09:55:18 UTC
When you say change content...Can you explain more?



If you have different content in server with different pages, you can use location.href="new page" on the onload event.



Or you can call the server side page with different paramaters.



There are different ways to do that , but mainly location.href="", will be the method you may have to use...



I hope this will help you
xer0blast
2008-11-17 05:51:46 UTC
you cant change it using javascript. use php.



javascript is a client side scripting and your talking about a server-side scripting.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...