473,657 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scaling images in IE

Hi,

I have a small javascript (scalegr.js) that re-scales a sequence of
images on a page to be less than the frame width, thus:

function scalegr(a) {
var imgs = document.images ;
var fw = window.innerWid th;
for (var i=0; i<imgs.length; i++) {
var w=imgs[i].width;
imgs[i].width = a*fw
}
}

Which is called from an HTML page as follows:

<HTML>
<HEAD>
<TITLE> Test Image Scaling</TITLE>
<script type='text/javascript' src='scalegr.js '></script>
</HEAD>
<body onload="javascr ipt:{if(parent. frames[0]&&parent.fra mes['navbar'].Go)parent.fram es['navbar'].Go();scalegr(0 .85)}"
onresize="javas cript:{scalegr( 0.85)}">
<H1>Image</H1>
<IMG SRC="trend1.gif " BORDER="0">
</BODY>
</HTML>

This works fine in Netscape/Mozilla but in IE, the images appear to
load (ie they are visible until loading completes) then they
disappear.

Any suggestions gratefully received, fixes to the above or a general
way of scaling my simple images to account for people with different
resolutions and/or not maximised browser displays.

Could you copy replies to my e-mail too, please (rcrump at une dot edu
dot au).

TIA.

Ron Crump
Jul 20 '05 #1
1 4289


Ron Crump wrote:
Hi,

I have a small javascript (scalegr.js) that re-scales a sequence of
images on a page to be less than the frame width, thus:

function scalegr(a) {
var imgs = document.images ;
var fw = window.innerWid th;
for (var i=0; i<imgs.length; i++) {
var w=imgs[i].width;
imgs[i].width = a*fw
}
}

Which is called from an HTML page as follows:

<HTML>
<HEAD>
<TITLE> Test Image Scaling</TITLE>
<script type='text/javascript' src='scalegr.js '></script>
</HEAD>
<body onload="javascr ipt:{if(parent. frames[0]&&parent.fra mes['navbar'].Go)parent.fram es['navbar'].Go();scalegr(0 .85)}"
onresize="javas cript:{scalegr( 0.85)}">
<H1>Image</H1>
<IMG SRC="trend1.gif " BORDER="0">
</BODY>
</HTML>

This works fine in Netscape/Mozilla but in IE, the images appear to
load (ie they are visible until loading completes) then they
disappear.

Any suggestions gratefully received, fixes to the above or a general
way of scaling my simple images to account for people with different
resolutions and/or not maximised browser displays.


The problem is that you use
window.innerWid th
which doesn't exist in IE's object model, there the property is
undefined. Thus you need
var fw;
if (typeof window.innerWid th != 'undefined')
fw = window.innerWid th;
}
else if (document.body && document.body.c lientWidth)
fw = document.body.c lientWidth

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8337
by: jeff | last post by:
Hiya, Im currently in the process of developing a picture browser, I want it to run off a CD, basically I have 2 questions for the group. The first is how do I get the program to only view the contents of the CD, at the moment i have a drop down drive menu that allows me to select the drive, i want to be able to put the CD in and then have i view only the CD contents, Ive considered just entering in my code D:\ but what happens if the...
11
16479
by: Stephane D'Alu | last post by:
Do you know if it is possible to have an image to be scalled to a maximum width/height, but with keeping its aspect ratio. The two ideas I had were: - <img src="toto.jpg" style="max-width: 200px; max-height: 200px;"/> but it doesn't keep the ratio - <div style="width: 200px; height: 200px;"><img src="toto.jpg/></div> but the image flow outside the div
1
1808
by: susie_richie_30 | last post by:
Hi, I am trying to apply gray scaling to color as well as black/white images. I have tried using the pixel by pixel approach to achieve the scaling. But the particular approach has a issue with high mega pixel images. Is there any other approach that can be applied to achieve the gray scaling and also have a reasonable performance?
3
2190
by: pratush | last post by:
hi. I am a bit new to graphics programing. I am trying in vb.net to make a 3 walled structure which'll give the look of 3d. for that purpose, I am using same rectangle filled with textured brush for 3 walls. For the center wall rectangle is to be drawn as is. For the side walls,I need a prespective plan view, so the rectangle and hence the images in textures should be scaled like in a trapezoidal fashion. But matrices and Drawimage...
3
2549
by: Larry Serflaten | last post by:
I am taking a 256 color bitmap from a file and scaling it up X 16 to a 32bppPARGB bitmap in memory. I copy that image to the screen. After scaling, the edges of all the lines and colors are blurred. I want the edges all crisp, including inherent pixelation (jaggies). Setting smoothing to none, or adjusting the composting mode on the Graphics object still
6
1980
by: Kajsa Anka | last post by:
I would like some advice, I'm going to build a small app that will, among other things, scale images so that they can be published on a web site. I've never done any image processing in python before so I would like to ask what is the best way of doing this, I will not do anything else than scaling the images. I found the Python Imaging Library but before I dive into that I would like to know if there is a better way of doing this.
3
2526
by: Yofnik | last post by:
Hello all, I need your help. Internet Explorer 6+ has a registry setting (UseHR) that will automatically scale images for displays with high resolution (DPI). I am building a web based monitoring application that has some very detailed graphs and charts. I DO NOT want these images scaled under any circumstances. In fact, my graphs look better on high DPI screens when the are not scaled.
4
6079
by: Sladan | last post by:
Hi! I'd like to scale some images for a poker game. I'm programming in C#. I haven't found any methods for scaling supporting compact framework. Any suggestions?
2
1926
by: Peter Oliphant | last post by:
I'm using the Bitmap class which has built in scaling for images been drawn not at their original size. And it works amazing well, and I'm VERY impressed! However. Is there perchance more than one method this uses that can be selectable? The one it uses is GREAT for photos, it kind of 'blurs' stuff together so it never pixelates. But I also have an image for which I wish it would just make the pixels 'larger'. That is, its an image...
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.