Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:18:45+00:00 2026-06-02T05:18:45+00:00

I am developing my first website and I have built an interactive photo gallery.

  • 0

I am developing my first website and I have built an interactive photo gallery. The main idea behind is that there is one large image displayed, if a user clicks this it changes to the next image. There is a also a thumbnail carousel below and this can be used to change to main image as well. I pretty much have this working as I would like (minus a few minor points with style etc). I then tried using the site on my iPhone and found that the photo gallery did not work as it had done on my desktop. What seems to happen is that when I click an image it reloads the page with the same image, not the next one in the list.

The way I have decided to code is that, the images are contained in anchor tags like:

<a class="nextphoto" href="" onclick="return false;">

When clicked jQuery catches the event and passes the appropriate parameters to the javascript function that updates the document with the new photo. This function called changePhoto() and creates an XMLHttpRequest to get the XML file that stores all the image names and alt information.

To view the photo gallery in its current state go to http://www.mwlets.co.uk/properties.html

I initially thought this would be a problem with iPhone not supporting javascript, jQuery or xml, but I seem to be able to find working examples of all of these things. I even tried the w3schools example of pulling information from an xml file and that worked fine.

My javascript code is:

    $(document).ready(function(){
      $("a.nextphoto").bind("click",function()
        {
          var imgID = document.getElementById("mainphoto").name;
          imgID++;
          changePhoto(imgID,false);
        });
});

$(document).ready(function(){
      $("a.prevphoto").bind("click",function()
        {
          var imgID = document.getElementById("mainphoto").name;
          imgID--;
          changePhoto(imgID,false);
        });
});

$(document).ready(function(){
      $("a.thumbnail").bind("click",function()
        {
          var currentID = document.getElementById("mainphoto").name;
          var thumbID = $(this).attr("name");
          if(currentID != thumbID)
            {
              changePhoto(thumbID,false);
            }
        });
});

function changePhoto(newimgID,slideshow)
    {
      var imgsrc = "http://www.mwlets.co.uk/Images/Mayfield/Large/to_let_mayfield_ashbourne_derbyshire_"
    var xmlhttp, images, imageName, imageAlt, imgalt;

 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
  }
 else
  {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

 xmlhttp.onreadystatechange=function()
  {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      images = xmlhttp.responseXML.documentElement.getElementsByTagName("IMAGE");

        if(newimgID > images.length)     
          {
              newimgID = 1;
          }
        if(newimgID < 1)
          {
            newimgID = images.length;
          }

      document.getElementById("mainphoto").name=newimgID;
      document.getElementById("photoindex").innerHTML=newimgID;

      imageName=images[newimgID - 1].getElementsByTagName("NAME");
      imgsrc += imageName[0].firstChild.nodeValue;
      document.getElementById("mainphoto").src=imgsrc;

      imageAlt=images[newimgID - 1].getElementsByTagName("ALT");
      imgalt = imageAlt[0].firstChild.nodeValue;
      document.getElementById("mainphoto").alt=imgalt;
      document.getElementById("captiontext").innerHTML=imgalt;   
    }
  }

 xmlhttp.open("GET","http://mwlets.co.uk/Images/Mayfield/image_list.xml",true);
 xmlhttp.send();

}

Individually I believe all the components should theoretically work on an iPhone. If anyone can suggest potential reasons why not that would be great.

I also realise that this is probably not the neatest way to code this. It is my first attempt at Javascript, jQuery and Ajax in a proper application. I’m open to suggestions for alternative ways to do this. My main requirements are that it sort of does what it’s doing on the site (as viewed from a desktop) at the moment, it is cross-brower/platform and is quick to retrieve the images. I am planning to gracefully degrade this code so that browsers without JS can view the images as a kind of frame style gallery.

Thanks in advance,

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:18:48+00:00Added an answer on June 2, 2026 at 5:18 am

    Safari is refreshing the page because of the empty href (I believe that’s standard Safari behavior). Try setting the click event via jQuery (you may not have to use anchor tags then). i.e $(“#picturelementid”).click(function{});

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that I built on the CodeIgniter framework. It implements the
I am currently developing a new website and have problems with IE7. First image
We have a website that deals with artists and venues and we're developing it
I am developing my first django website. I have written code in my view
I am developing a website by ASP.Net. I have created settings/first-run page which I
I'm developing my first MVC website and I'm experimenting with the few available grids
I been developing a website with MVC3/EFCode First/C#, everything ok, I tested multiple times
Hi Stack Overflow community. I'm developing a wordpress website for Satan. First of all,
I have been developing my first TCP/Socket based application with Apache Mina, it looks
I have been developing a login library for a website using CodeIgniter. The authentication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.