PDA

View Full Version : WIDTH and HEIGHT according to the resolution of the screen...


rickysorus
09-26-2002, 10:24 AM
Hello,

Can you help me for a very precise script:

I would like to be able to determine the WIDTH and the HEIGHT according to the resolution of the screen of the guest!

Example:

If the resolution of the screen is 800x600 or less, I want to show the image under the size: 525x350 and...
If the resolution of the screen is 1024x768 or more, I want to show the image under the size: 750x500

Thanks you...

x_goose_x
09-27-2002, 02:27 AM
Try something like:


<script>
function loader() {
sw = parseInt(screen.width);
if (sw==640) {
document.getElementById("imag1").setAttribute("width",10);
document.getElementById("imag1").setAttribute("height",10);
}else if(sw==800) {
document.getElementById("imag1").setAttribute("width",20);
document.getElementById("imag1").setAttribute("height",20);
}else if(sw==1024) {
document.getElementById("imag1").setAttribute("width",30);
document.getElementById("imag1").setAttribute("height",30);
}else if(sw==1152) {
document.getElementById("imag1").setAttribute("width",40);
document.getElementById("imag1").setAttribute("height",40);
}
window.onload=loader;
</script>

<img src="mypic.jpg" id="imag1">

rickysorus
09-27-2002, 04:53 PM
Thank you for your response !

I try your script but it don't work !

I always have an error in the page !

I try just the script without anything and the error is still there !


You or somebody have a solution?

I looked for hours and hours on Internet and I begins to despair!


Thank you...

adios
09-27-2002, 05:13 PM
Don't despair....

document.getElementById("imag1").setAttribute("height",40);
}
}
window.onload=loader;

rickysorus
09-28-2002, 03:16 AM
Yeah.....

The script work for an html page but it don't work in my php page !

The image don't take the "imag1" variable !

Do you know the solution for this...

Thank you very much for all.... :-)

x_goose_x
09-29-2002, 08:03 PM
Try playing around with

document.images[3].setAttribute("src","myimage.jpg");

rickysorus
10-06-2002, 08:47 AM
Thank you very much !

You're a great team...


Bye...:thumbsup: