[thelist] Javascript - screen size change broken in IE
Stephen Rider
evolt_org at striderweb.com
Fri Feb 25 13:09:41 CST 2005
Hi --
I'm not much of a Javascript person, but my company was provided with
some code that was so broken that even _I_ could tell. I've been
working on this for a while now, and have it working perfectly in
Firefox.
The overall function is that clicking on a link on the page "index.htm"
uses Javascript to draw a new window and write HTML into it. This
entire javascript shown below, wherein I am having the problem, is
written into this new window by the script that creates it, as the new
window itself has javascript functions of its own.
To see it in action, go here and click on any of the "camera" icons on
the floor plan:
<http://www.realtymort.com/neighborhoods/lincolnpark/fp-530warlington/
studio1/>
also, the code is below in this email....
In IE 5.5, preloader() works fine, but swapImage() does not -- it seems
to crash. (the popup source changes to index.htm -- see explanation
below)
In Safari, the image changes, but the window is not resized.
ANY ADVICE regarding the Javascript is greatly appreciated. I'm sure
there are ways to tighten this up.
Thanks and Regards,
Steve Rider
Here's the code and HTML:
<script type="text/javascript" language="JavaScript" charset="utf-8">
// <![CDATA[
var imagesrc;
var imagesrcHR;
var magplus;
var magminus;
var winwidth;
var winwidthHR;
var winheight;
var winheightHR;
var large;
function preloader() {
imagesrc = "living2.jpg";
imagesrcHR = "living2HR.jpg";
magplus = "/neighborhoods/img/magplus.gif";
magminus = "/neighborhoods/img/magminus.gif";
winwidth = 360;
winwidthHR = 799;
winheight = 270;
winheightHR = 599;
large = 0;
lgphoto = new Image();
lgphoto.src = imagesrcHR;
smphoto = new Image();
smphoto.src = imagesrc;
iconplus = new Image();
iconplus.src = magplus;
iconminus = new Image();
iconminus.src = magminus;
}
function swapImage() {
if (large == 1) {
document.photo.src = imagesrc;
document.photo.width = winwidth;
document.photo.height = winheight;
document.icon.src = magplus;
large = 0;
window.resizeTo(winwidth+30, winheight+130);
}
else {
document.photo.src = imagesrcHR;
document.photo.width = winwidthHR;
document.photo.height = winheightHR;
document.icon.src = magminus;
large = 1;
window.resizeTo(winwidthHR+30, winheightHR+130);
}
}
function DN() {}
// ]]>
</script>
Here's the entire Body of the popup involved:
<body onload="javascript:preloader()">
<p align="center"><img src="living2.jpg" name="photo"
alt="living2.jpg" title="" width="360" height="270" /></p>
<p align="center">View 5 - Living Area<br />
<span id="maglink"><a href="" onclick="swapImage(); return
false;"><img src="/neighborhoods/img/magplus.gif" id="icon" width="32"
height="32" alt="magnify" title="magnify" align="left" style="border:
0px;" /></a></span></p>
</body>
More information about the thelist
mailing list