Click to See Complete Forum and Search --> : Javascript page zoom in browsers


windinthew
07-15-2003, 09:34 AM
Hi

IE and Netscape have no inbuilt image zoom and IE does not seem able to increase text size on many pages hardcoded with CSS as an absolute font size. However I found the script below which zooms all images in the page if set as the address of a link - if you load a page then press a links button with the script below , all images are zoomed. My question - does anyone know a modification to the script which will zoom the whole page (text and images) ? Opera browser has a page zoom but I do not like that browser much


javascript:(function(){ function zoomImage(image, amt) { if(image.initialHeight
== null) { /* avoid losing height information due to integer rounding while
zooming out */ image.initialHeight = image.height; image.initialWidth =
image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width
= image.scalingFactor * image.initialWidth; image.height = image.scalingFactor *
image.initialHeight; } for (i=0; i<document.images.length; ++i)
zoomImage(document.images[i], 2); })();

cacalex
07-17-2003, 08:43 AM
Maybe this will help you :

<HTML>
<HEAD>
<TITLE>Test de Zoom...</TITLE>
<script language="javascript">
function R1024()
{
var wdth = 1024; //Change this variable to match your configuration
document.body.style.zoom = screen.width/1024;
document.Fm.TxAre.value=1024;
alert("1024 ? : "+screen.width/1024);
}

function R800()
{
var wdth = 800; //Change this variable to match your configuration
document.body.style.zoom = screen.width/800;
document.Fm.TxAre.value=800;
alert("800 ? : "+screen.width/800);
}

function R640()
{
var wdth = 640; //Change this variable to match your configuration
document.body.style.zoom = screen.width/640;
document.Fm.TxAre.value=640;
alert("640 ? : "+screen.width/640);
}
</script>
</HEAD>
<BODY>
<FORM name="Fm">
<CENTER>

<INPUT name="TxAre" TYPE="text" NAME="Texte" SIZE=40 MAXLENGTH=40>

<BR>
<BR>
<Button onclick="R1024()">1024</Button>
<BR>
<Button onclick="R800()">800</Button>
<BR>
<Button onclick="R640()">640</Button>
<BR>
<Button onclick="window.opener=null;window.close()">CLOSE</Button>
<BR>
<BR>

</CENTER>
</FORM>

</BODY>
</HTML>

But it is zooming the WHOLE page (scrollbars too)
It is zooming to a screen resolution.
Try it !!!

windinthew
07-17-2003, 11:49 AM
Hi

Thank you for post... what you said is fine if I wanted visitors to zoom my own webpages but what I was seeking was a script that would be the address of a browser links button which when pressed would zoom the current page -like the script I wrote about which zooms the images. Maybe it would look something like

javascript:(function(){ function R640()
{
var wdth = 640; //Change this variable to match your configuration
document.body.style.zoom = screen.width/640;
document.Fm.TxAre.value=640;
alert("640 ? : "+screen.width/640); ()}

but this does not work - perhaps the syntax is wrong


Thanks for your interest !

cacalex
07-17-2003, 01:14 PM
Sorry, i didn't look at your script as i should...

Well, i don't say it is impossible, but i don't know a way to do what you are asking...

Can you send anyway an example of your script ???
I'm curious about it, and i'd like to look at it...

windinthew
07-18-2003, 08:24 AM
Hi There

Thanks for your interest again. My concern with this is as more and more web sites use font size set in absolute terms via CSS, IE will not zoom the text in these cicumstances.

Below is my original posting with the script that works via a link button to enlarge all images in the page.

Opera Browser has a built in zoom of the whole page but there are other things I do not like about it.... and you can get a plug in from the net called IE booster that gives a page zoom but it is a three stage operation. I assume both carry out the zoom via Javascript.

>>>>>>>>>>


IE and Netscape have no inbuilt image zoom and IE does not seem able to increase text size on many pages hardcoded with CSS as an absolute font size. However I found the script below which zooms all images in the page if set as the address of a link - if you load a page then press a links button with the script below , all images are zoomed. My question - does anyone know a modification to the script which will zoom the whole page (text and images) ? Opera browser has a page zoom but I do not like that browser much


javascript function(){ function zoomImage(image, amt) { if(image.initialHeight
== null) { /* avoid losing height information due to integer rounding while
zooming out */ image.initialHeight = image.height; image.initialWidth =
image.width; image.scalingFactor = 1; } image.scalingFactor *= amt; image.width
= image.scalingFactor * image.initialWidth; image.height = image.scalingFactor *
image.initialHeight; } for (i=0; i<document.images.length; ++i)
zoomImage(document.images[i], 2); })();

Best wishes