Reply to topic  [ 10 posts ] 
Javascript slideshow 
Author Message
Spends far too much time on here
User avatar

Joined: Fri Apr 24, 2009 8:38 am
Posts: 2967
Location: Dorchester, Dorset
Reply with quote
I'm putting a JavaScript slideshow in the portfolio section of my website. I know some of you browse with JavaScript turned off, but that's a pretty rare thing, so I'm not too bothered about people doing that as they'd made a conscious effort to switch it off and would expect reduced browsing as a result, but I was wondering if JavaScript will work okay with the iPhone and other smartphones?

If this is going to be a problem, I'm also going to have to come up with a solution to show something else if JavaScript is disabled. I know nothing about JavaScript and have used a free plugin to create it. If this is going to be a problem, I'll post a link and maybe one of you clever folk would be able to point me in the right direction to sorting it out.

Cheers all.

_________________
I've finally invented something that works!

A Mac User.


Mon Dec 07, 2009 1:52 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Tue May 05, 2009 3:29 pm
Posts: 7173
Reply with quote
tombolt wrote:
I'm putting a JavaScript slideshow in the portfolio section of my website.


Somewhere, Nick is having a heart attack. :shock:

_________________
timark_uk wrote:
That's your problem. You need Linux. That'll fix all your problems.
Mark


Mon Dec 07, 2009 2:00 pm
Profile
Spends far too much time on here
User avatar

Joined: Fri Apr 24, 2009 8:38 am
Posts: 2967
Location: Dorchester, Dorset
Reply with quote
Linux_User wrote:
Somewhere, Nick is having a heart attack. :shock:


Yeah! I understand not liking unnecessary use of javascript, but sometimes there's just no other way of doing it. Actually, I could have done this in flash, but it would have taken about twenty times as long.

_________________
I've finally invented something that works!

A Mac User.


Mon Dec 07, 2009 2:21 pm
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
If you are going to do it, then the best way to go about it is by having what you want to display to non-javascript browsers show as default.

Then, you can use JavaScript to pull that out of the page and put your slideshow in.

It might come as a pretty big surprise to hear that I actually did something myself for a site I made for someone a few years ago.

Code:
<script language="javascript" type="text/javascript">
<!--
var dimages=new Array();
dimages[0]=new Image();
dimages[0].src="assets/images/image_container/3Beckham2005003.jpg"
dimages[1]=new Image();
dimages[1].src="assets/images/image_container/Linda'sGallery015.jpg"
dimages[2]=new Image();
dimages[2].src="assets/images/image_container/Linda'sGallery017.jpg"
dimages[3]=new Image();
dimages[3].src="assets/images/image_container/Mibby2003.jpg"
dimages[4]=new Image();
dimages[4].src="assets/images/image_container/Studio001.jpg"
dimages[5]=new Image();
dimages[5].src="assets/images/image_container/TorsoBronze003.jpg"
dimages[6]=new Image();
dimages[6].src="assets/images/image_container/scan0008.jpg"
dimages[7]=new Image();
dimages[7].src="assets/images/image_container/scan0010.jpg"
dimages[8]=new Image();
dimages[8].src="assets/images/image_container/000_0314.JPG"
dimages[9]=new Image();
dimages[9].src="assets/images/image_container/009.JPG"
dimages[10]=new Image();
dimages[10].src="assets/images/image_container/BoscSpa003(2).JPG"
dimages[11]=new Image();
dimages[11].src="assets/images/image_container/BoscSpa006(2).JPG"
dimages[12]=new Image();
dimages[12].src="assets/images/image_container/DSC00002.JPG"
dimages[13]=new Image();
dimages[13].src="assets/images/image_container/DSCN0790.JPG"
dimages[14]=new Image();
dimages[14].src="assets/images/image_container/DSCN0800.JPG"
dimages[15]=new Image();
dimages[15].src="assets/images/image_container/DSCN0847.JPG"
dimages[16]=new Image();
dimages[16].src="assets/images/image_container/DSCN0888.JPG"
dimages[17]=new Image();
dimages[17].src="assets/images/image_container/Dubai05.08005.JPG"
dimages[18]=new Image();
dimages[18].src="assets/images/image_container/Dubai05.08010.JPG"
dimages[19]=new Image();
dimages[19].src="assets/images/image_container/P05-08-09_2222[01].JPG"
dimages[20]=new Image();
dimages[20].src="assets/images/image_container/P05-08-09_2224[01].JPG"
dimages[21]=new Image();
dimages[21].src="assets/images/image_container/P07-07-09_2059.JPG"
dimages[22]=new Image();
dimages[22].src="assets/images/image_container/P13-05-09_1454.JPG"
dimages[23]=new Image();
dimages[23].src="assets/images/image_container/P26-05-09_1259[01].JPG"
dimages[24]=new Image();
dimages[24].src="assets/images/image_container/PROFILEWORKSHOPNINA047.JPG"
var numImages=25;
var curImage=-1;
function swapPicture()
{
  if (document.images)
  {
    var nextImage=curImage+1;
    if (nextImage>=numImages)
      nextImage=0;
    if (dimages[nextImage] && dimages[nextImage].complete)
    {
      var target=0;
      if (document.images.myImage)
        target=document.images.myImage;
      if (document.all && document.getElementById("myImage"))
        target=document.getElementById("myImage");
 
      // make sure target is valid.  It might not be valid
      //   if the page has not finished loading
      if (target)
      {
        target.src=dimages[nextImage].src;
        curImage=nextImage;
      }
      setTimeout("swapPicture()", 5000);
    }
    else
    {
      setTimeout("swapPicture()", 500);
    }
  }
}
setTimeout("swapPicture()", 5000);
//-->
</script>


This particular example uses PHP to create the array, but I'm sure there are some JavaScript functions available to do the same thing.

When the page loads, PHP throws a random image into the container. If they have JavaScript enabled, then that image will change periodically. If they don't have JavaScript enabled it will remain the same, and only change when they refresh the page.

_________________
Image


Fri Dec 18, 2009 4:49 pm
Profile
Spends far too much time on here
User avatar

Joined: Fri Apr 24, 2009 8:38 am
Posts: 2967
Location: Dorchester, Dorset
Reply with quote
That sounds ideal, thanks Nick.

_________________
I've finally invented something that works!

A Mac User.


Tue Dec 22, 2009 10:50 am
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
No worries.

By the way, I tested on my iPhone and that JavaScript runs fine - the images switch just as they do on a 'real' computer.

I also tried it on a PC and it works just as it does on a 'real' computer. ;)

_________________
Image


Thu Dec 24, 2009 12:05 am
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
Note: Adobe, Microsoft, Apple and Mozilla have all recommended their users turn off JavaScript this year - Mozilla currently says anybody not using versions 3.0.16 or 3.5.6 of Firefox should immediately disable JavaScript until they can upgrade due to in-the-wild exploits.

Adobe also currently recommend that all users of all versions of Acrobat and Reader disable JavaScript until the next quarterly patch cycle (January 12th), where version 9.12 of both Acrobat and Reader will be updated.

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Tue Dec 29, 2009 7:08 am
Profile ICQ
Spends far too much time on here
User avatar

Joined: Fri Apr 24, 2009 8:38 am
Posts: 2967
Location: Dorchester, Dorset
Reply with quote
big_D wrote:
Note: Adobe, Microsoft, Apple and Mozilla have all recommended their users turn off JavaScript this year - Mozilla currently says anybody not using versions 3.0.16 or 3.5.6 of Firefox should immediately disable JavaScript until they can upgrade due to in-the-wild exploits.

Adobe also currently recommend that all users of all versions of Acrobat and Reader disable JavaScript until the next quarterly patch cycle (January 12th), where version 9.12 of both Acrobat and Reader will be updated.


Interesting, that hasn't filtered down to me, so I suspect a lot of people will not have heard to have done that! Doesn't that seriously reduce the functionality of sites like Facebook?

_________________
I've finally invented something that works!

A Mac User.


Wed Dec 30, 2009 10:46 am
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
It has been in the news section of PC Pro, IT Pro, Mac User, ZDNet and CNet over the last couple of weeks... :?

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Wed Dec 30, 2009 1:31 pm
Profile ICQ
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
tombolt wrote:
big_D wrote:
Note: Adobe, Microsoft, Apple and Mozilla have all recommended their users turn off JavaScript this year - Mozilla currently says anybody not using versions 3.0.16 or 3.5.6 of Firefox should immediately disable JavaScript until they can upgrade due to in-the-wild exploits.

Adobe also currently recommend that all users of all versions of Acrobat and Reader disable JavaScript until the next quarterly patch cycle (January 12th), where version 9.12 of both Acrobat and Reader will be updated.


Interesting, that hasn't filtered down to me, so I suspect a lot of people will not have heard to have done that! Doesn't that seriously reduce the functionality of sites like Facebook?


It probably would, although I'd like to think that those sites would degrade properly I doubt they would work without JavaScript. You might get a nice message telling you that you don't have JavaScript turned on and that you need it. :roll:

_________________
Image


Thu Dec 31, 2009 6:10 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.