Jump to content

Re-call a script


Kovo

Recommended Posts

How could I,say, reset the sequential script after it has loaded already.For example, say I load the page and the script executes. How can I reset the script so that it re-executes and re-shows all the content without refreshing the page(using onclick etc...)?Thanks

<script type="text/javascript">/************************************************ Sequential Content Revealer- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)* Visit DynamicDrive.com for hundreds of original DHTML scripts* This notice must stay intact for legal use***********************************************/var contentpause=1000 //customize time each content should pause for before the next one is revealed (1000=1 second)var once_session=0 //Should "reveal" animation only be applied once per browser session? (0=no, 1=yes):var curobjindex=0var orderoffset=100function collectElementbyClass(){var classname="revealcontent"glidearray=new Array()var inc=0var alltags=document.all? document.all : document.getElementsByTagName("*")for (i=0; i<alltags.length; i++){if (alltags[i].className==classname){glidearray[inc++]=alltags[i]glidearray[inc-1].displayorder=(glidearray[inc-1].getAttribute("displayorder"))? parseInt(glidearray[inc-1].getAttribute("displayorder")) : inc+orderoffset}}if (glidearray.length>0){glidearray.sort(compareorder)seqreveal()}}function seqreveal(){if (curobjindex<glidearray.length){glidearray[curobjindex].style.visibility="visible"var actualpause=(glidearray[curobjindex].getAttribute("pausesec"))? parseFloat(glidearray[curobjindex].getAttribute("pausesec"))*1000 : parseFloat(contentpause)glidetimer=setTimeout("seqreveal()",actualpause)curobjindex++}}function compareorder(a, b){return a.displayorder-b.displayorder}function get_cookie(Name) {var search = Name + "="var returnvalue = ""if (document.cookie.length > 0) {offset = document.cookie.indexOf(search)if (offset != -1) {offset += search.lengthend = document.cookie.indexOf(";", offset)if (end == -1)end = document.cookie.length;returnvalue=unescape(document.cookie.substring(offset, end))}}return returnvalue;}if (once_session && get_cookie("textdisplayed")=="" || !once_session){if (window.addEventListener)window.addEventListener("load", collectElementbyClass, false)else if (window.attachEvent)window.attachEvent("onload", collectElementbyClass)else if (document.getElementById)window.onload=collectElementbyClassif (once_session)document.cookie="textdisplayed=yes"}elsedocument.write('<style>\n.revealcontent{visibility:visible;}\n</style>')</script>

http://dynamicdrive.com/dynamicindex17/seqreveal.htm

Link to comment
Share on other sites

Without looking too deeply at what this script does, I would suggest that you try adding the following function to your java script:

function doItAgain(){	curobjindex=0;	collectElementbyClass();}

And then calling that new function in a button's onclick event in the HTML:

<button onclick="doItAgain();">Start it Again!</button>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...