How to set the image be auto-resize?

Posted on 2012-08-16
Last Modified: 2012-08-19
Dear EE experts,

We would like to ask for tech support on where & how to set the images be auto-resize when view in different state of browser. If the browser be maximize, we would like to set the image be maximize its width too.
kindly check the attached embed script for reference:

<!-- Begin
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = 'IMG/xg-header-00.jpg'
theImages[1] = 'IMG/xg-header-01.jpg'
theImages[2] = 'IMG/xg-header-02.jpg'
theImages[3] = 'IMG/xg-header-03.jpg'
theImages[4] = 'IMG/IL-header.jpg'

// do not edit anything below this line

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');

//  End -->


    	<!-- Begin
		//  End -->

Open in new window

Thank you and hope to hear soon...
Question by:Stiebel Eltron
    LVL 49

    Accepted Solution

    Have you already experimented with using width='100%' by replacing line 27 from
    document.write('<img src="'+theImages[whichImage]+'">');

    Open in new window

    document.write('<img src="'+theImages[whichImage]+'" width="100%" />');

    Open in new window


    Author Closing Comment

    by:Stiebel Eltron
    More than 500 pts, can? Excellent!

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    The viewer will learn how to dynamically set the form action using jQuery.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now