I have a Random Quote feature which works through a Javascript file. You can see it at the right column on this page http://www.wise-quotes.com/ However, I don't know why the Javascript file doesn't always run, you can see no random quote being displayed when it doesn't run. You need to refresh a few times, then you can see the random quote. However, if you browse the Javascript file directly (http://www.wise-quotes.com/tools/random-quote.js), you can see random quote being generated every time! Why? Any idea? Thanks.
That's maybe because your script is located in the body tag? Try to add it in the head tag, generate the quote, create an element (a span or a p) and append the element created to the quote container. something like this: in the script file: // create the element var theSpan = document.createElement("span"); // add the quote to span // you could use a function to generate the quote text var theContent = "your quote here"; theSpan.appendChild(theContent); // When the page loads, append the Span to the quote container var container = document.getElementById("you quote container id"); container.appendChild(theSpan); Code (markup):
Hi, I am not too sure if I know how to do this. But basically, I need to add something like: <span name="you quote container id"></span> Code (markup): at the place where I want to show the quote? Anyway, this may not be the cause of the problem because I got the idea to do this from another quote website. The js file is just like what I have, and it works good. I mean, that js file can be placed wherever I want in the body, no need anything in the head tag.