473,769 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random Image transitions with BG changer?

77 New Member
Hello, Im using the background image change script below and I want to change each image with a transition, swipe, circle in, circleout etc randomly.
Not sure how to make random transitions with each changing image. please assist. (if possible cross browser compatible), if not should degrade in other browsers.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script LANGUAGE="JavaScript">
  3. <!--
  4. var BackgroundChangeIndex = 0;
  5.  
  6. var wistol = new Array
  7. ("http://i14.photobucket.com/albums/a345/Instar/greenbgfade17oi.jpg", "http://i14.photobucket.com/albums/a345/Instar/rsntort1024-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/WesternDiamondBackRattlesnake-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptile_003-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptileCopperheadSnake-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/turtlesbg-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptile_001-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Picture163-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/NzCommonGreenGeckoCloseup-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/crocodile_3-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/FijianSkinkEatingEarwig-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/HornedLizard-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/1113330679_1280-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Croc-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Chameleon_Wallpaper_by_phreeza-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/1113330784_1280-1.jpg"); 
  8.  
  9. function SetBackgroundImage()
  10. {
  11. var BackgroundImage;
  12. BackgroundChangeIndex++;
  13. if (BackgroundChangeIndex >= wistol.length)
  14. {
  15. BackgroundChangeIndex = 0;
  16. }
  17. BackgroundImage = wistol[BackgroundChangeIndex]
  18. document.body.style.cssText="background: url(" + BackgroundImage + ");" + "background-attachment: fixed; center; center;"
  19.  
  20. setTimeout("SetBackgroundImage()", 10000) 
  21.  
  22. }
  23. window.onload = SetBackgroundImage;
  24. //-->
  25. </script>
  26.  
  27.  
Nov 12 '07 #1
6 1633
Inny
77 New Member
This is the effect I want Except The images should rotate automatically like the above script,(no onclick)
I cannot work out how to combine the two.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. var photos=new Array()
  4. var photoslink=new Array()
  5. var which=0
  6.  
  7. //define images. You can have as many as you want:
  8. photos[0]="http://i14.photobucket.com/albums/a345/Instar/greenbgfade17oi.jpg"
  9. photos[1]="http://i14.photobucket.com/albums/a345/Instar/rsntort1024-1.jpg"
  10. photos[2]="http://i14.photobucket.com/albums/a345/Instar/WesternDiamondBackRattlesnake-1.jpg"
  11. photos[3]="http://i14.photobucket.com/albums/a345/Instar/reptile_003-1.jpg"
  12. photos[4]="http://i14.photobucket.com/albums/a345/Instar/reptileCopperheadSnake-1.jpg"
  13. photos[5]="http://i14.photobucket.com/albums/a345/Instar/turtlesbg-1.jpg"
  14. photos[6]="http://i14.photobucket.com/albums/a345/Instar/reptile_001-1.jpg"
  15. photos[7]="http://i14.photobucket.com/albums/a345/Instar/Picture163-1.jpg"
  16. photos[8]="http://i14.photobucket.com/albums/a345/Instar/NzCommonGreenGeckoCloseup-1.jpg"
  17. photos[9]="http://i14.photobucket.com/albums/a345/Instar/crocodile_3-1.jpg"
  18. photos[10]="http://i14.photobucket.com/albums/a345/Instar/FijianSkinkEatingEarwig-1.jpg"
  19. photos[11]="http://i14.photobucket.com/albums/a345/Instar/HornedLizard-1.jpg"
  20. photos[12]="http://i14.photobucket.com/albums/a345/Instar/1113330679_1280-1.jpg"
  21. photos[13]="http://i14.photobucket.com/albums/a345/Instar/Croc-1.jpg"
  22. photos[14]="http://i14.photobucket.com/albums/a345/Instar/Chameleon_Wallpaper_by_phreeza-1.jpg"
  23. photos[15]="http://i14.photobucket.com/albums/a345/Instar/1113330784_1280-1.jpg"
  24.  
  25.  
  26.  
  27. //Specify whether images should be linked or not (1=linked)
  28. var linkornot=0
  29.  
  30. //Set corresponding URLs for above images. Define ONLY if variable linkornot equals "1"
  31. photoslink[0]=""
  32. photoslink[1]=""
  33. photoslink[2]=""
  34.  
  35. //do NOT edit pass this line
  36.  
  37. var preloadedimages=new Array()
  38. for (i=0;i<photos.length;i++){
  39. preloadedimages[i]=new Image()
  40. preloadedimages[i].src=photos[i]
  41. }
  42.  
  43.  
  44. function applyeffect(){
  45. if (document.all && photoslider.filters){
  46. photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
  47. photoslider.filters.revealTrans.stop()
  48. photoslider.filters.revealTrans.apply()
  49. }
  50. }
  51.  
  52.  
  53.  
  54. function playeffect(){
  55. if (document.all && photoslider.filters)
  56. photoslider.filters.revealTrans.play()
  57. }
  58.  
  59. function keeptrack(){
  60. window.status="Image "+(which+1)+" of "+photos.length
  61. }
  62.  
  63.  
  64. function backward(){
  65. if (which>0){
  66. which--
  67. applyeffect()
  68. document.images.photoslider.src=photos[which]
  69. playeffect()
  70. keeptrack()
  71. }
  72. }
  73.  
  74. function forward(){
  75. if (which<photos.length-1){
  76. which++
  77. applyeffect()
  78. document.images.photoslider.src=photos[which]
  79. playeffect()
  80. keeptrack()
  81. }
  82. }
  83.  
  84. function transport(){
  85. window.location=photoslink[which]
  86. }
  87.  
  88.  
  89. </script>
  90.  
  91. <script>
  92. if (linkornot==1)
  93. document.write('<a href="javascript:transport()">')
  94. document.write('<img src="'+photos[0]+'" name="photoslider" style="filter:revealTrans(duration=2,transition=23)" border=0>')
  95. if (linkornot==1)
  96. document.write('</a>')
  97. </script>
  98.  
  99.  
  100.    <a href="#" onClick="backward();return false">Previous Slide</a></td>
  101.     <td width="50%" height="21"><p align="right"><a href="#" onClick="forward();return false">Next Slide</a>
  102.  
Nov 12 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
Copy applyEffect and playEffect and call them above and below line 17 (respectively) in your first script.

This will only work in IE.

Hope that helps.
Nov 12 '07 #3
Inny
77 New Member
Copy applyEffect and playEffect and call them above and below line 17 (respectively) in your first script.

This will only work in IE.

Hope that helps.
Not sure what arguments im using to call the functions? Im not that well versed in JS

I did this but still no transistions affects???? Help Im Clueless!

Expand|Select|Wrap|Line Numbers
  1. <script LANGUAGE="JavaScript">
  2. <!--
  3. var BackgroundChangeIndex = 0;
  4.  
  5. var wistol = new Array
  6. ("http://i14.photobucket.com/albums/a345/Instar/greenbgfade17oi.jpg", "http://i14.photobucket.com/albums/a345/Instar/rsntort1024-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/WesternDiamondBackRattlesnake-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptile_003-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptileCopperheadSnake-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/turtlesbg-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptile_001-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Picture163-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/NzCommonGreenGeckoCloseup-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/crocodile_3-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/FijianSkinkEatingEarwig-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/HornedLizard-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/1113330679_1280-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Croc-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Chameleon_Wallpaper_by_phreeza-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/1113330784_1280-1.jpg"); 
  7.  
  8. function SetBackgroundImage()
  9. {
  10. var BackgroundImage;
  11. BackgroundChangeIndex++;
  12. if (BackgroundChangeIndex >= wistol.length)
  13. {
  14. BackgroundChangeIndex = 0;
  15. }
  16. BackgroundImage = wistol[BackgroundChangeIndex]
  17. function applyeffect(){
  18. if (document.all && photoslider.filters){
  19. photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*23)
  20. photoslider.filters.revealTrans.stop()
  21. photoslider.filters.revealTrans.apply()
  22. }
  23. }
  24. document.body.style.cssText="background: url(" + BackgroundImage + ");" + "background-attachment: fixed; center; center;"
  25. function playeffect(){
  26. if (document.all && photoslider.filters)
  27. photoslider.filters.revealTrans.play()
  28. }
  29.  
  30. setTimeout("SetBackgroundImage()", 10000) 
  31.  
  32. }
  33. window.onload = SetBackgroundImage;
  34. //-->
  35. </script>
  36.  
Nov 12 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
Not sure what arguments im using to call the functions? Im not that well versed in JS

I did this but still no transistions affects?
I meant copying the functions above the code, but calling the functions at those positions:
Expand|Select|Wrap|Line Numbers
  1. applyeffect();
  2. document.body.style.cssText="background: url(" + BackgroundImage + ");" + "background-attachment: fixed; center; center;";
  3. playeffect();
No arguments are needed.

You will also need to change the functions themselves to apply to document.body rather than 'photoslider'.
Nov 13 '07 #5
Inny
77 New Member
like this? not working,still no transistions, am i wasting my time here?

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4.  
  5. <script LANGUAGE="JavaScript">
  6. <!--
  7.  
  8. function applyEffect(){
  9. if (document.all && document.body.style.cssText.filters){
  10. document.body.filters.revealTrans.Transition=Math.floor(Math.random()*23)
  11. document.body.filters.revealTrans.stop()
  12. document.body.filters.revealTrans.apply()
  13. }
  14. }
  15.  
  16. function playEffect(){
  17. if (document.all && document.body.filters)
  18. document.body.filters.revealTrans.play()
  19. }
  20.  
  21.  
  22.  
  23. var BackgroundChangeIndex = 0;
  24. var wistol = new Array
  25. ("http://i14.photobucket.com/albums/a345/Instar/greenbgfade17oi.jpg", "http://i14.photobucket.com/albums/a345/Instar/rsntort1024-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/WesternDiamondBackRattlesnake-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptile_003-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptileCopperheadSnake-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/turtlesbg-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/reptile_001-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Picture163-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/NzCommonGreenGeckoCloseup-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/crocodile_3-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/FijianSkinkEatingEarwig-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/HornedLizard-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/1113330679_1280-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Croc-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/Chameleon_Wallpaper_by_phreeza-1.jpg", "http://i14.photobucket.com/albums/a345/Instar/1113330784_1280-1.jpg"); 
  26.  
  27.  
  28. function SetBackgroundImage()
  29. {
  30. var BackgroundImage;
  31. BackgroundChangeIndex++;
  32. if (BackgroundChangeIndex >= wistol.length)
  33. {
  34. BackgroundChangeIndex = 0;
  35. }
  36.  
  37.  
  38. BackgroundImage = wistol[BackgroundChangeIndex]
  39.  
  40.  
  41. applyEffect();
  42. document.body.style.cssText="background: url(" + BackgroundImage + ");" + "background-attachment: fixed; center; center;";
  43.  
  44.  
  45. playEffect();
  46.  
  47. setTimeout("SetBackgroundImage()", 10000) 
  48.  
  49. }
  50. window.onload = SetBackgroundImage;
  51. //-->
  52. </script>
  53.  
  54.  
  55.  
Nov 13 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
To tell you the truth, I don't use filters much because they only work in IE.

It almost seems correct except on line 5, instead of checking for filters on cssText, check document.body.f ilters as you have done on line 13.

Whenever you test for something before using it (to avoid errors), only test the thing you're going to use, so in this case, there's no need to check for document.all.
Nov 14 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3536
by: Olly | last post by:
I've found a basic script, however I also need to add alt and title attributes as well, how would I go about doing this? Here's the script I found: Thanks <script language="JavaScript"> <!-- /*
5
2592
by: Linda | last post by:
Greetings: I have found a random image script that I like. It is located here: http://www.javascriptcity.com/scripts/local/simage3.htm I'd like to edit this to have 4 different slots for images with a different set of 5 images for each slot, something like this page: http://www.uchsc.edu The script says /* no need to edit past this point (unless you want to
5
2194
by: Haydnw | last post by:
Hi, I have the code below as code-behind for a page which displays two images. My problem is with the second bit of code, commented as " 'Portfolio image section". Basically, the SQL query gets details of a random image from an access database. I know this works because when I run the query in access, it picks a different image each time (or close enough). However, when I view the .aspx page that this code-behind is for, it always picks...
1
3154
by: Dan | last post by:
Hi, I was wondering if anyone could come up with a cross browser image transition that I could use... I have already made one that works in IE but i know it doesn't work in Mozilla Firefox. Below is the script I have made, there is only one error with it (besides compatabilty), the fact that you can make the images transition even when there is already a transition occuring, I have tried to compensate for this, but it doesn't work......
6
3074
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional) file path to store image resource object contents * @see actual_path */
7
2350
by: Spartanicus | last post by:
Afaik the use of a <noscriptelement is frowned upon nowadays. For a JS random image changer I tried to use a replacement by having the script change the HTML src attribute value of an img element. The trouble is that in some situations like over slow connections (on initial load when the JS is in an external file), or with a slow client the image specified in the HTML starts to load and display before it's changed by the script. This I'm...
4
3082
by: Kim | last post by:
Random image downloader for specified newsgroup. Hi I'm writing a small script that will download random images from a specified newsgroup. I've imported yenc into the script but I can't open the image or save it. This is my first script so be gentle! Heres the script ####random group downloader#### import nntplib import string, random import mimetools import StringIO
3
3591
by: fran7 | last post by:
Hi, I have this nice code that returns a random image database record. It works great. What I am trying to do now is to be able to get the "alt" description for the image from another field. If I add another field to the query it returns two images. I was making the alt alt=""" & recordset(i) & """ but I know that must be wrong. well it works but returns the image name, ie images/friday.jpg. Anyone know how I can get it to return the image...
2
17635
by: Ron Poulton | last post by:
A recent project involved me obtaining a random image from the Web and using it in some specific fashion. I chose to use PHP to access Google Images for a random image URL. The image could be generic or related to a specific topic. Here's the PHP function that queries Google Images and returns an image URL: function GetRandomImageURL($topic='', $min=0, $max=100) { // get random image from Google if ($topic=='') $topic='image'; ...
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.