Re: Problem with Image display on separate window
- From: bruce barker <nospam@xxxxxxxxxx>
- Date: Mon, 12 Feb 2007 16:51:53 -0800
you need to use a window.setTimeout() to do the loop. a better approach is to render the image size with the name, so that when client script opens the img, it can pre-specify the size which has better usability.
-- bruce (sqlwork.com)
tshad wrote:
"bruce barker" <nospam@xxxxxxxxxx> wrote in message news:eWMnBUuTHHA.3592@xxxxxxxxxxxxxxxxxxxxxxx.you are correct. setting the src starts a download, you should check readyState of the image before checking the size.
I have been reading on this and found there are problems trying get this to work. Correctly. Sometime looping causes infinite loops and out of memory errors.
Is there a way around this?
Also, is there some type of hide window function? I am trying open the window in a hidden state until the image is loaded and resized before I display it. Right now I get this sort of post back type of look where the window is opened and then resized and the window that called it is redrawn and it looks clumsy.
Thanks,
Tom-- bruce (sqlwork.com)
tshad wrote:Could this be that the image is not totally loaded yet?
The first thing it does is load the image into the image tag:
document.LogoDisplay.src = "..\\..\\uploads\\" + opener.document.getElementById('Logo').innerHTML;
Then it gets the size of the image:
id = document.getElementById("LogoDisplay");
w = id.width+10;
h = id.height+50;
is it possible by the time I get to this set of code only part of the image is loaded and the all subsequent times it is getting the image from some cache that is quicker?
I can't think of any other reason that would cause this?
Thanks,
Tom
"tshad" <t@xxxxxxxx> wrote in message news:%23SHCO8tTHHA.5108@xxxxxxxxxxxxxxxxxxxxxxxThis was posted before but the message got messed up (all NLs were stripped
out for some reason).
I have 2 labels that hold the name of different images on my .aspx page.
<asp:Label ID="Logo" runat="server"/>
<asp:Label ID="CompanyPicture" runat="server"/>
I have 2 links that open the windows to preview these images. The previewed
images are done on separate html pages that do nothing but display the
image.
function OpenLogoPreviewWindow()
{
window.open('logoDisplay.htm','myWindow','menubar=no,toolbar=no,directories=no,resizable=no,scrollbars=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{
window.open('CompanyPictureDisplay.htm','myWindow','menubar=no,toolbar=no,directories=no,resizable=no,scrollbars=no,location=no,status=no');
}
This works most of the time. But the first time you do it, it has the wrong
dimensions. For example, for the CompanyPicture - the size is 502 by
400.The very first time a machine loads this picture, it will be incorrect.
It will be something like 38 by 87. From that point on it will be correct.
Even if I change the picture - it will size it correctly. It will also work
correctly if I reboot the machine.
To test it I need to go to another machine that has
never run it. The code for each page is:
LogoDisplay.htm
*********************************************************
function entry()
{
//alert("In LogoDisplay");
document.LogoDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('Logo').innerHTML;
id = document.getElementById("LogoDisplay");
w = id.width+10;
h = id.height+50;
// alert ("w = " + w + " h = " + h);
window.resizeTo(w,h);
if (screen) {
x = (screen.availHeight - h)/2;
y = (screen.availWidth - w)/2;
}
window.moveTo(y,x);
window.focus();
}
</script>
</head>
<body onLoad="entry()">
<img name="LogoDisplay">
</body>
</html>
*********************************************************
CompanyPictureDisplay.htm
**********************************************************
function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').innerHTML;
id = document.getElementById("PictureDisplay");
w = id.width+10;
h = id.height+50;
// alert ("w = " + w + " h = " + h);
window.resizeTo(w,h);
if (screen) {
x = (screen.availHeight - h)/2;
y = (screen.availWidth - w)/2;
}
window.moveTo(y,x);
window.focus();
}
</script>
</head>
<body onLoad="entry()">
<img name="PictureDisplay">
</body>
</html>
****************************************************************
Thanks,
Tom
- Follow-Ups:
- References:
- Problem with Image display on separate window
- From: tshad
- Re: Problem with Image display on separate window
- From: tshad
- Re: Problem with Image display on separate window
- From: bruce barker
- Re: Problem with Image display on separate window
- From: tshad
- Problem with Image display on separate window
- Prev by Date: Getting reference to controls within ItemTemplate in a repeater
- Next by Date: Re: Formatting string with end of line
- Previous by thread: Re: Problem with Image display on separate window
- Next by thread: Re: Problem with Image display on separate window
- Index(es):
Relevant Pages
|
Loading