Jump to content

flowe

Members
  • Posts

    5
  • Joined

  • Last visited

flowe's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi Foxy Mod with your kind and patient "shoe horn" activity, my - and my customers - idea is successfully implemented. Using your last proposal and what I've learned in this thread, I now have 4 banners with individual holding times and switching like clockwork. Many thanks! This is the whole and final working code - never mind any possibly retro elements... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title></title></head><script style = "text/javascript" >var rollover = [ "_band-emo-308x70.jpg", "_band-nis-308x70.jpg", "_band-rab-308x70.jpg", "_band-nis-308x70.jpg"];var intervals = [ 7000, 7000, 4000, 35000];var number = 0;var hold = 7000;var lg = intervals.length;setTimeout(change, hold); // holding preloaded emofunction change() { number++; if (number == lg ) { number = 0 }; document.getElementById("rollover").src = rollover[number]; hold = intervals[number]; setTimeout(change, hold);}</script><div style="position:absolute; top:0px; left:0px;"><img id="rollover" src="_band-emo-308x70.jpg" alt="image" width="308" height="70"></div></html>
  2. Hi Foxy Mod Thanks again - and back again. The two banners script works flawlessly as you suggested, but I failed miserably on expanding it to three banners, with banner nis appearing as every second and the other two alternating in first position. Incredible to implant an undetectable killer in just few lines... This works: <script style = "text/javascript" >var rollover = [ // creating array by [...] "_band-emo-308x70.jpg", // rollover[item0] "_band-nis-308x70.jpg" // rollover[item1]];var number = 1;var hold = 7000;setTimeout(change, hold);function change() { document.getElementById("rollover").src = rollover[number]; if (number == 1) { number = 0; hold = 35000; } else { number = 1; hold = 7000; } setTimeout(change, hold);}</script> And this doesn't: <script type="text/javascript">var rollover = [ "_band-emo-308x70.jpg", "_band-nis-308x70.jpg", "_band-rab-308x70.jpg"];var number = 1;var hold = 7000;var flag = emo;setTimeout(change, hold);function change() { document.getElementById("rollover").src = rollover[number]; if (number == 1) { hold = 35000; if (flag == emo ) { number = 2; flag = rab; } if (flag == rab ) { number = 0; flag = emo; } } else { hold = 7000; number = 1; } setTimeout(change, hold);}</script> Please correct... many thanks flowe
  3. Hi Foxy Mod Thanks again for your input. Your ready made solution solved my real life problem. As you see, as a non-professional I'm fairly out of date regarding JS. But I've learned several new tricks - as the best appears 'var rollover [ ..., ... ]'. I don't understand 'calling the function by reference'. Could you please elaborate? Why doesn't it work after adding the () to 'change()'? And why does it work again in Chrome/IE11/FF browsers after making it a string '"change()"'? I didn't find any in-depth explanation in 'JavaScript Function Invocation' in the JS Tutorial. I 'invoked' http://validator.w3.org/ and 'earned' several errors, but none related to the issue just mentionned. Another question: JS Tutorial proposes to use plain <script></script> statements, but validator demands <script type="text/javascript">. To me, it generally appears to be rather difficult to obtain conclusive advice... Anyhow, thanks so far - Henry
  4. Hi Foxy Mod Great many thanks for the friendly and profound answer. I'm sure it works without me fully understanding it yet, but I'll try and learn... Henry.
  5. Hi everybody I have a rollover with 2 images, changing endlessly at equal intervals. This is easily done using setInterval and makes no trouble. Now I want the 2 images to change at unequal intervals. I thought this would be easy too and wrote the attached code. But I can't bring it to work, whatever I try. Would anybody please help me? Many thanks and kind regards - Henry <html><head><title>…</title></head><script style = "text/javascript" >var rollover = new Array();rollover[0] = new Image(); rollover[0].src ="image_n_308x70.jpg";rollover[1] = new Image(); rollover[1].src ="image_d_308x70.jpg";var i = 0;var number = 0;var hold = 5000;while ( i == 0) {setTimeout( "change()", hold );function change() {document.rollover.src = rollover[number].src;if (nummer == 0) {number = 1; hold = 1000;} else {number = 0; hold = 5000;}}</script><body><img name="rollover" src="image_n_308x70.jpg" alt="" width="308" height="70"></body></html>
×
×
  • Create New...