Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to have this work a few times on one page....

    I've been Googling like crazy.. .. I really really would like to have this javascript appear a few times on my site.. .. It's one of those picture slideshow things.. .. Hmmmmmm. I don't know how . I sincerely thank you for the solution , or direction to the solution .... Here it is:


    <p align="center"><input type="button" name="btnPrev" value="&lt;&lt;---" onclick="Prev();">&nbsp; <span id="_Ath_Img_X"></span> &nbsp;of&nbsp;<span id="_Ath_Img_N"></span> &nbsp;<input type="button" name="btnNext" value="---&gt;&gt;" onclick="Next();"></p>
    <span id="_Ath_FileName"><font color="#666666"><small></span><p align="center"><img name="_Ath_Slide" onload="OnImgLoad()" height="125" width="125"></p></p><p align="center"><script language="JavaScript1.2" event="onload" for="window">main();</script><script language="JavaScript1.2">
    g_fPlayMode = 0;g_iimg = 0;g_imax = 0;g_ImageTable = new Array();function ChangeImage(fFwd){if (fFwd){if (++g_iimg==g_imax)g_iimg=0;}else{if (g_iimg==0)g_iimg=g_imax; g_iimg--;}Update();}function Update(){document.all._Ath_Slide.src = g_ImageTable[g_iimg][0]; document.all._Ath_FileName.innerHTML = g_ImageTable[g_iimg][1];document.all._Ath_Img_X.innerHTML = g_iimg + 1;document.all._Ath_Img_N.innerHTML = g_imax;}function Play(){g_fPlayMode = !g_fPlayMode;if (g_fPlayMode){btnPrev.disabled = btnNext.disabled = true;Next();}else {btnPrev.disabled = btnNext.disabled = false;}} function OnImgLoad(){if (g_fPlayMode)window.setTimeout("Tick()", g_dwTimeOutSec*1000);}function Tick() {if (g_fPlayMode)Next();} function Prev(){ChangeImage(false);}function Next(){ChangeImage(true);}function main(){Update();}

    g_ImageTable[g_imax++] = new Array ("http://www.picture-url.com/.jpg", "<a href='http'>description</a>");
    g_ImageTable[g_imax++] = new Array ("http://www.picture-url.com/.jpg", "<a href='http'>description</a>");
    g_ImageTable[g_imax++] = new Array ("http://www.picture-url.com/.jpg", "<a href='http'>description</a>");

    g_dwTimeOutSec=2
    window.onload=Play
    </script></p>

    Best wishes...

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Use an OO-based Slideshow script like this. The source can be found here.

  • #3
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there no other way?
    I found this as a possible soloution(( thanx to javascriptkit.com)):

    The way to go about solving this conflict is simple, though not quite the same to explain. Essentially, what you want is to end up with only ONE delta for both scripts, with that delta calling the two scripts. Let's list some possible scenarios now, and their resolutions:

    EXAMPLE #1:
    SCRIPT 1: <body onload="dothis()">
    SCRIPT 2: <body onload="dothat()">
    RESOLUTION: <body onload="dothis();dothat()">

    EXAMPLE #2:
    SCRIPT 1: <body onload="dothis()">
    SCRIPT 2: window.onload=dothat()
    RESOLUTION: <body onload="dothis();dothat()">

    EXAMPLE #3:
    SCRIPT 1: window.onload=dothis
    SCRIPT 2: window.onload=dothat
    RESOLUTION: <body onload="dothis();dothat()">

    As you can see, regardless of whether the two scripts contain "delta" or "beta", the resolution is the same- remove BOTH lines, and call the scripts directly within the <body> tag, each separated by a semicolon. If you wish to combine three scripts, the procedure is the exact same.

    By using the above technique, both scripts are called and executed, as opposed to just one- or neither. In other words, conflict avoided! Check out http://www.javascriptkit.com/javatut...taction4.shtml for some additional information on resolving script conflicts. Good luck!
    ------------------
    but after changing this-that woohoo..grr ..I this no figure out..
    I really like this little slideshow thing---took a while to customize it and make it perfect---I'll be updating a lot, so it's a good one for it ..
    I don't know much about it... Any suggestions, or is the above not likely to happen...
    Thanx..

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your script was not written to be used multiple times on a page. Every variable used within the script is in the global scope and if more than one instance of the script is running on a page the multiple instances of these global variables will conflict with eachother.

    If you insist on using multiple instances of this script you will need to change all the variable and function names so that each is unique along with moving the multiple function calls to the body onload handler as you described above...

    I concur with Glenn and also suggest that you look for another script which was written to be object orientated....

    .....Willy

  • #5
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanx for the direction
    --Spent a couple hours trying to change everything..., but did not work;
    --Tried to figure out how the suggested OO-based one works..., no luck yet, but will continue until I've got it.......

    !!!!!!! Thanx !!!!!!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •