By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,773 Members | 1,793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,773 IT Pros & Developers. It's quick & easy.

Problem with Image display on separate window

P: n/a
This 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,scrollba rs=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{
window.open('CompanyPictureDisplay.htm','myWindow' ,'menubar=no,toolbar=no,directories=no,resizable=n o,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').i nnerHTML;
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

Feb 12 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
This 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,scrollba rs=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{

window.open('CompanyPictureDisplay.htm','myWindow' ,'menubar=no,toolbar=no,directories=no,resizable=n o,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').i nnerHTML;
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



Feb 12 '07 #2

P: n/a
you are correct. setting the src starts a download, you should check
readyState of the image before checking the size.

-- 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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>This 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,scrollb ars=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').innerHTM L;
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



Feb 12 '07 #3

P: n/a
"bruce barker" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
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').innerHTM L;

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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>This 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','menuba r=no,toolbar=no,directories=no,resizable=no,scroll bars=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{

window.open('CompanyPictureDisplay.htm','myWindo w','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


Feb 12 '07 #4

P: n/a
"tshad" <t@home.comwrote in message
news:eY**************@TK2MSFTNGP05.phx.gbl...
"bruce barker" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
>you are correct. setting the src starts a download, you should check
readyState of the image before checking the size.
I tried to set this but got a "ReadyState = Undefined" in my test alert box
in the following:

************************************************
function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').i nnerHTML;
id = document.getElementById("PictureDisplay");
alert("id ReadyState = " + id.ReadyState);
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>
***********************************

PictureDisplay is an img on the page. Do I need to set it up differently to
test the ReadyState?

Thanks

Tom
>
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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
This 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','menub ar=no,toolbar=no,directories=no,resizable=no,scrol lbars=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{

window.open('CompanyPictureDisplay.htm','myWind ow','menubar=no,toolbar=no,directories=no,resizabl e=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').innerHTM L;
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


Feb 13 '07 #5

P: n/a

"tshad" <t@home.comwrote in message
news:uI**************@TK2MSFTNGP03.phx.gbl...
"tshad" <t@home.comwrote in message
news:eY**************@TK2MSFTNGP05.phx.gbl...
>"bruce barker" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
>>you are correct. setting the src starts a download, you should check
readyState of the image before checking the size.

I tried to set this but got a "ReadyState = Undefined" in my test alert
box in the following:
Found out my problem here - it is readyState not ReadyState.

I am still curious about the other 2 problems.

Thanks,

Tom
>
************************************************
function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').i nnerHTML;
id = document.getElementById("PictureDisplay");
alert("id ReadyState = " + id.ReadyState);
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>
***********************************

PictureDisplay is an img on the page. Do I need to set it up differently
to test the ReadyState?

Thanks

Tom
>>
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').innerHTM L;

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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl. ..
This 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','menu bar=no,toolbar=no,directories=no,resizable=no,scro llbars=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{
>
window.open('CompanyPictureDisplay.htm','myWin dow','menubar=no,toolbar=no,directories=no,resizab le=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').innerHT ML;
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
>
>
>
>
>


Feb 13 '07 #6

P: n/a
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" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
>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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
This 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','menub ar=no,toolbar=no,directories=no,resizable=no,scrol lbars=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{

window.open('CompanyPictureDisplay.htm','myWind ow','menubar=no,toolbar=no,directories=no,resizabl e=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').innerHTM L;
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


Feb 13 '07 #7

P: n/a
"bruce barker" <no****@nospam.comwrote in message
news:ej**************@TK2MSFTNGP02.phx.gbl...
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.
Not sure what you mean on the pre-specifying the size.

But I couldn't really get the setTimeout to work or using a pause type of
scenario and I assume this is why others couldn't either. What happens is
when you are in a loop (while loop or for loop of x iterations to simulate
milliseconds) it seems to be gobbling up the cpu (as it is running as fast
as it can) and no work gets done until the loop is finished.

For example, I tried:

********************************
function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').i nnerHTML;
id = document.getElementById("PictureDisplay");

for (var x = 1; x <= 10; x++)
{
if (id.readyState == "complete") break;
pauseIt(10000);
}

alert("id after for loop ReadyState = " + id.readyState + " x = " + x);
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();
alert("id ReadyState = " + id.readyState);
}
function pauseIt(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}
***********************************************

This would come back as uninitialized after the for loop and would still
seem to work fine. The last alert would show it as complete.

I need to find a way to make it wait about 10 seconds for each loop (without
some time of other loop) while the image is being loaded. In this case, it
will usually only use one loop to load the image. It is normally loaded in
about 1 or 2 seconds (if even that long - if cached).

Thanks,

Tom
>
-- bruce (sqlwork.com)
tshad wrote:
>"bruce barker" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
>>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').innerHTM L;

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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl. ..
This 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','menu bar=no,toolbar=no,directories=no,resizable=no,scro llbars=no,location=no,status=no');
}
function OpenPicturePreviewWindow()
{
>
window.open('CompanyPictureDisplay.htm','myWin dow','menubar=no,toolbar=no,directories=no,resizab le=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').innerHT ML;
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
>
>
>
>
>

Feb 13 '07 #8

P: n/a
I finally got the setTimeout to work and it seems to work pretty well.

I am curious as to why the large image loads quick after the first time it
loads on any machine. I assume it is cached on the local machine and have
been trying to get rid of it for testing by going to tools/"internet
options" and press the Delete Temporary Internet files including offline
content. But this doesn't seem to work.

Anyone know how to get rid of the Cache that my local machine is using (if
in fact that is what happened).

Here is what I did to fix my image load problem using setTimeout - might
help someone else.
************************************************** *************
<script language="JavaScript">
//window.resizeTo(400, 400);
var id;
var ktr = 0;

function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').i nnerHTML;
id = document.getElementById("PictureDisplay");
setTimeout("resizeIt()",50);
}
function resizeIt ()
{
ktr=ktr+1;
if (ktr 3000)
{
// alert("ktr in resizeIt = " + ktr);
return;
}
if (id.readyState != "complete")
{
// alert("ktr in resizeIt = " + ktr + " readyState = " + id.readyState);
setTimeout("resizeIt()",50);
}
else
{
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();
// alert("id ReadyState = " + id.readyState + " ktr = " + ktr);
}
}
</script>
</head>
<body onLoad="entry()">
<img name="PictureDisplay">
</body>
</html>
************************************

Thanks,

Tom
"tshad" <t@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
"bruce barker" <no****@nospam.comwrote in message
news:ej**************@TK2MSFTNGP02.phx.gbl...
>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.

Not sure what you mean on the pre-specifying the size.

But I couldn't really get the setTimeout to work or using a pause type of
scenario and I assume this is why others couldn't either. What happens is
when you are in a loop (while loop or for loop of x iterations to simulate
milliseconds) it seems to be gobbling up the cpu (as it is running as fast
as it can) and no work gets done until the loop is finished.

For example, I tried:

********************************
function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').i nnerHTML;
id = document.getElementById("PictureDisplay");

for (var x = 1; x <= 10; x++)
{
if (id.readyState == "complete") break;
pauseIt(10000);
}

alert("id after for loop ReadyState = " + id.readyState + " x = " + x);
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();
alert("id ReadyState = " + id.readyState);
}
function pauseIt(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}
***********************************************

This would come back as uninitialized after the for loop and would still
seem to work fine. The last alert would show it as complete.

I need to find a way to make it wait about 10 seconds for each loop
(without some time of other loop) while the image is being loaded. In
this case, it will usually only use one loop to load the image. It is
normally loaded in about 1 or 2 seconds (if even that long - if cached).

Thanks,

Tom
>>
-- bruce (sqlwork.com)
tshad wrote:
>>"bruce barker" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
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').innerHT ML;
>
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@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
>This 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','men ubar=no,toolbar=no,directories=no,resizable=no,scr ollbars=no,location=no,status=no');
>}
>function OpenPicturePreviewWindow()
>{
>>
>window.open('CompanyPictureDisplay.htm','myWi ndow','menubar=no,toolbar=no,directories=no,resiza ble=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').innerH TML;
>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('CompanyPictur e').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
>>
>>
>>
>>
>>


Feb 13 '07 #9

P: n/a
Well, I thought this was working - which it was until I looked at IE7.

Now, IE7 puts an address bar at the top of the picture below the title bar.
This isn't the normal address bar that you type in but one that just shows
theURL. Is this another security restriction???

This is getting very irritating. I finally get it working and a new browser
messes it up.

Is there someway to get rid of this bar? All of my windows are wrong now.

Thanks,

Tom
"tshad" <t@home.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I finally got the setTimeout to work and it seems to work pretty well.

I am curious as to why the large image loads quick after the first time it
loads on any machine. I assume it is cached on the local machine and have
been trying to get rid of it for testing by going to tools/"internet
options" and press the Delete Temporary Internet files including offline
content. But this doesn't seem to work.

Anyone know how to get rid of the Cache that my local machine is using (if
in fact that is what happened).

Here is what I did to fix my image load problem using setTimeout - might
help someone else.
************************************************** *************
<script language="JavaScript">
//window.resizeTo(400, 400);
var id;
var ktr = 0;

function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture').i nnerHTML;
id = document.getElementById("PictureDisplay");
setTimeout("resizeIt()",50);
}
function resizeIt ()
{
ktr=ktr+1;
if (ktr 3000)
{
// alert("ktr in resizeIt = " + ktr);
return;
}
if (id.readyState != "complete")
{
// alert("ktr in resizeIt = " + ktr + " readyState = " + id.readyState);
setTimeout("resizeIt()",50);
}
else
{
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();
// alert("id ReadyState = " + id.readyState + " ktr = " + ktr);
}
}
</script>
</head>
<body onLoad="entry()">
<img name="PictureDisplay">
</body>
</html>
************************************

Thanks,

Tom
"tshad" <t@home.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>"bruce barker" <no****@nospam.comwrote in message
news:ej**************@TK2MSFTNGP02.phx.gbl...
>>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.

Not sure what you mean on the pre-specifying the size.

But I couldn't really get the setTimeout to work or using a pause type of
scenario and I assume this is why others couldn't either. What happens
is when you are in a loop (while loop or for loop of x iterations to
simulate milliseconds) it seems to be gobbling up the cpu (as it is
running as fast as it can) and no work gets done until the loop is
finished.

For example, I tried:

********************************
function entry()
{
document.PictureDisplay.src = "..\\..\\uploads\\" +
opener.document.getElementById('CompanyPicture'). innerHTML;
id = document.getElementById("PictureDisplay");

for (var x = 1; x <= 10; x++)
{
if (id.readyState == "complete") break;
pauseIt(10000);
}

alert("id after for loop ReadyState = " + id.readyState + " x = " + x);
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();
alert("id ReadyState = " + id.readyState);
}
function pauseIt(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
}
***********************************************

This would come back as uninitialized after the for loop and would still
seem to work fine. The last alert would show it as complete.

I need to find a way to make it wait about 10 seconds for each loop
(without some time of other loop) while the image is being loaded. In
this case, it will usually only use one loop to load the image. It is
normally loaded in about 1 or 2 seconds (if even that long - if cached).

Thanks,

Tom
>>>
-- bruce (sqlwork.com)
tshad wrote:
"bruce barker" <no****@nospam.comwrote in message
news:eW**************@TK2MSFTNGP03.phx.gbl...
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').innerH TML;
>>
>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@home.comwrote in message
>news:%2****************@TK2MSFTNGP06.phx.gbl. ..
>>This 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','me nubar=no,toolbar=no,directories=no,resizable=no,sc rollbars=no,location=no,status=no');
>>}
>>function OpenPicturePreviewWindow()
>>{
>>>
>>window.open('CompanyPictureDisplay.htm','myW indow','menubar=no,toolbar=no,directories=no,resiz able=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').inner HTML;
>>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('CompanyPictu re').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
>>>
>>>
>>>
>>>
>>>



Feb 13 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.