Jump to content

What is better?


The Little Guy

Recommended Posts

What would you do?

 

OK I have 2 images for each image one set at 50% and one at 100% in width and height.

 

The operation:

Option 1: The browser loads the first 50% sized image. When it is clicked, it removes that image and loads the 100% sized image using AJAX and PHP. When the larger image is clicked it goes back to the 50% sized image then has to reload that.

 

Option 2: The browser loads 2 images the 50% sized image and 100% sized image. The 100% sized image is defaulted to a display of none using CSS while the 50% sized is shows. Javascript is then used to change the display type of each one depending on the image they are viewing.  This is 100 times faster than the other way when zooming in and out, but requires loading 2 images.

Link to comment
Share on other sites

I personally would do something like this:

 


<style type="text/css">

.big {width:100%;height:100%}
.small {width:50%;height:50%}

</style>


<script language="javascript">

function increaseXY(myImage)
{
document.getElementById(myImage).className='big';
document.getElementById(myImage).onclick=function() {
  decreaseXY(myImage);
}
}

function decreaseXY(myImage)
{
document.getElementById(myImage).className='small';
document.getElementById(myImage).onclick=function() {
  increaseXY(myImage);
}
}


</script>


<img id="pic" class="small" src="somepicture.jpg" onclick="increaseXY('pic')">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.