IE7 window.open and resizeby problem

M

Mike McCollister

I have a JavaScript function that I use to open up an image in a popup
window when someone clicks on an image. It works fine in IE6 but in IE7 when
I try to do a resizeBy to resize the window due to the scrollbar height the
image does not come up sometimes. Does anyone know how to fix this?

I've included my function. below.

Thanks,

Mike

function DisplayImage(image, width, height, title, date)
{
var newWin;
var winName;
var title2 = unescape(title);
var newTitle = title2;
var newDate;
var ieVersion = GetInternetExplorerVersion();

html = "";

title2 = "some code remove here";

html += "<html>" + endl;
html += "<head>" + endl;
html += "<title>" + newTitle + ": " + newDate + "</title>" + endl;
html += "</head>" + endl;
html += "<script>" + endl;
html += "function PlaySound(url) {html += document.all.sound.src =
url;}";
html += "</script>" + endl;
html += "<body bgcolor='#FFFFFF' topmargin='0' leftmargin='0' " +
"marginheight='0' marginwidth='0'>" + endl;
html += "<p align='center'>" + endl;
html += "<a href='javascript:window.close()'>" +
"<img src='" + imageDir + "/" + image + "' width='" + width +
"' height='" + height + "' alt='' " +
"title='Click to Close Window' border='0'></a>" + endl;
html += "</p>" + endl;
html += "<font face='Arial'>" + endl;
html += "<p align='center'><b>" + title2 + "</b><br>" + endl;
html += date + "</p><p></p>" + endl;
html += "</font>" + endl;
html += "</body>" + endl;
html += "</html>";

newWin = window.open("", "photoWindow", //winName,
"width=" + width +
",height=" + height +
",menubar=yes" +
",resizable=yes" +
",scrollbars=yes",
true);

// resize window only for Microsoft Internet Explorer
if(navigator.appName == "Microsoft Internet Explorer")
{
// ???? PROBLEMS HERE IN IE7 ?????
if((ieVersion >= 4) && (ieVersion <= 6))
{
// I don't know why this needs to be done
newWin.document.writeln("<html><body></body></html>");

// do the resize
newWin.resizeBy(width - newWin.document.body.clientWidth,
height - newWin.document.body.clientHeight);
}
}

newWin.document.writeln(html);
newWin.document.close();
newWin.focus();
}
 
S

Stefan B Rusynko

And what happen if you change the line to
if((ieVersion >= 4) && (ieVersion <= 7))

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


|I have a JavaScript function that I use to open up an image in a popup
| window when someone clicks on an image. It works fine in IE6 but in IE7 when
| I try to do a resizeBy to resize the window due to the scrollbar height the
| image does not come up sometimes. Does anyone know how to fix this?
|
| I've included my function. below.
|
| Thanks,
|
| Mike
|
| function DisplayImage(image, width, height, title, date)
| {
| var newWin;
| var winName;
| var title2 = unescape(title);
| var newTitle = title2;
| var newDate;
| var ieVersion = GetInternetExplorerVersion();
|
| html = "";
|
| title2 = "some code remove here";
|
| html += "<html>" + endl;
| html += "<head>" + endl;
| html += "<title>" + newTitle + ": " + newDate + "</title>" + endl;
| html += "</head>" + endl;
| html += "<script>" + endl;
| html += "function PlaySound(url) {html += document.all.sound.src =
| url;}";
| html += "</script>" + endl;
| html += "<body bgcolor='#FFFFFF' topmargin='0' leftmargin='0' " +
| "marginheight='0' marginwidth='0'>" + endl;
| html += "<p align='center'>" + endl;
| html += "<a href='javascript:window.close()'>" +
| "<img src='" + imageDir + "/" + image + "' width='" + width +
| "' height='" + height + "' alt='' " +
| "title='Click to Close Window' border='0'></a>" + endl;
| html += "</p>" + endl;
| html += "<font face='Arial'>" + endl;
| html += "<p align='center'><b>" + title2 + "</b><br>" + endl;
| html += date + "</p><p></p>" + endl;
| html += "</font>" + endl;
| html += "</body>" + endl;
| html += "</html>";
|
| newWin = window.open("", "photoWindow", //winName,
| "width=" + width +
| ",height=" + height +
| ",menubar=yes" +
| ",resizable=yes" +
| ",scrollbars=yes",
| true);
|
| // resize window only for Microsoft Internet Explorer
| if(navigator.appName == "Microsoft Internet Explorer")
| {
| // ???? PROBLEMS HERE IN IE7 ?????
| if((ieVersion >= 4) && (ieVersion <= 6))
| {
| // I don't know why this needs to be done
| newWin.document.writeln("<html><body></body></html>");
|
| // do the resize
| newWin.resizeBy(width - newWin.document.body.clientWidth,
| height - newWin.document.body.clientHeight);
| }
| }
|
| newWin.document.writeln(html);
| newWin.document.close();
| newWin.focus();
| }
|
|
 
M

Mike McCollister

The window will open and size correclty but the second and third times the
window will fill the whole screen.

Mike

Stefan B Rusynko said:
And what happen if you change the line to
if((ieVersion >= 4) && (ieVersion <= 7))

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


message |I have a JavaScript function that I use to open up an image in a popup
| window when someone clicks on an image. It works fine in IE6 but in IE7
when
| I try to do a resizeBy to resize the window due to the scrollbar height
the
| image does not come up sometimes. Does anyone know how to fix this?
|
| I've included my function. below.
|
| Thanks,
|
| Mike
|
| function DisplayImage(image, width, height, title, date)
| {
| var newWin;
| var winName;
| var title2 = unescape(title);
| var newTitle = title2;
| var newDate;
| var ieVersion = GetInternetExplorerVersion();
|
| html = "";
|
| title2 = "some code remove here";
|
| html += "<html>" + endl;
| html += "<head>" + endl;
| html += "<title>" + newTitle + ": " + newDate + "</title>" + endl;
| html += "</head>" + endl;
| html += "<script>" + endl;
| html += "function PlaySound(url) {html += document.all.sound.src =
| url;}";
| html += "</script>" + endl;
| html += "<body bgcolor='#FFFFFF' topmargin='0' leftmargin='0' " +
| "marginheight='0' marginwidth='0'>" + endl;
| html += "<p align='center'>" + endl;
| html += "<a href='javascript:window.close()'>" +
| "<img src='" + imageDir + "/" + image + "' width='" + width +
| "' height='" + height + "' alt='' " +
| "title='Click to Close Window' border='0'></a>" + endl;
| html += "</p>" + endl;
| html += "<font face='Arial'>" + endl;
| html += "<p align='center'><b>" + title2 + "</b><br>" + endl;
| html += date + "</p><p></p>" + endl;
| html += "</font>" + endl;
| html += "</body>" + endl;
| html += "</html>";
|
| newWin = window.open("", "photoWindow", //winName,
| "width=" + width +
| ",height=" + height +
| ",menubar=yes" +
| ",resizable=yes" +
| ",scrollbars=yes",
| true);
|
| // resize window only for Microsoft Internet Explorer
| if(navigator.appName == "Microsoft Internet Explorer")
| {
| // ???? PROBLEMS HERE IN IE7 ?????
| if((ieVersion >= 4) && (ieVersion <= 6))
| {
| // I don't know why this needs to be done
| newWin.document.writeln("<html><body></body></html>");
|
| // do the resize
| newWin.resizeBy(width - newWin.document.body.clientWidth,
| height - newWin.document.body.clientHeight);
| }
| }
|
| newWin.document.writeln(html);
| newWin.document.close();
| newWin.focus();
| }
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Why won't this code work??? 1
NEED HELP IN FIXING A CODE 2
This HTML won't work!! 5
css and images 7
Aligning trouble 4
Pages in Inline frames 1
Outlook signature problem 0
second page 1

Top