froded
08-03-2007, 12:29 PM
1) Script Title: DHTML Window widget (v1.03)
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm
3) Describe problem: Hi. First thank you for a great script to show inline popup windows ! I was up and running in no time.
I'm using the Widget to show a full size JPEG picture in a iframe popup triggered by a mouseover event on a thumbnail image. Is there any way to resize the DTML window to the content so that the whole picture is viewed without scroll bars?
I'm having trouble referencing the correct object using only the window handle. I really miss a ".contentDoc" reference to the popup window content. Here is what I got so far:
// global variables for inline popup
var picturewin; //reference to the new inline popup window
var already_open=0; //global variable to show whether an new popup window should be created or an old reused
function ShowPopImage(url, headertext){
if (already_open>0){
// only refresh content
// alert("already open");
picturewin.load("iframe", url, headertext);
var target=window.frames["_iframe-"+picturewin.id].document.body
if (target) {
// this works in IE7 ...
// alert(target.scrollHeight + target.offsetHeight - target.clientHeight)
picturewin.setSize( (target.scrollWidth + target.offsetWidth - target.clientWidth),(target.scrollHeight + target.offsetHeight - target.clientHeight));
}
else {
//alert("not a object")
}
}
else {
// first time setup
already_open=1;
//alert("first time open");
picturewin=dhtmlwindow.open("PictureView", "iframe", url, headertext, "width=590px,height=350px,top=40px,left=300px,resize=1,scrolling=1,center=0")
picturewin.onclose=function(){already_open=0; return true;} // set our global variable to false to show window is no longer open
picturewin.setSize(300, 400);
picturewin.moveTo(320, 20);
picturewin.show();
}
}
While this works to some degree, it's limited to IE7 and only calculates the size of the iframe, not the whole popup. Some scrollbars occur on the first resize, but may be ok on the next... Seems to me the page content must be fully loaded before a resize can be triggered, and in this case also it needs several iterations.
Hope you can give me some ideas on how to do this correctly. Do I need to read the size of the main div in the widget, and if so how to reference it ?
Maybe the needed "ResizeToContentSize" code could be added to the Widget features in the future? You already wrote a better iframe resize script : http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm. Hope you can include this into the Widget.
Best regards
Frode Dragland
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm
3) Describe problem: Hi. First thank you for a great script to show inline popup windows ! I was up and running in no time.
I'm using the Widget to show a full size JPEG picture in a iframe popup triggered by a mouseover event on a thumbnail image. Is there any way to resize the DTML window to the content so that the whole picture is viewed without scroll bars?
I'm having trouble referencing the correct object using only the window handle. I really miss a ".contentDoc" reference to the popup window content. Here is what I got so far:
// global variables for inline popup
var picturewin; //reference to the new inline popup window
var already_open=0; //global variable to show whether an new popup window should be created or an old reused
function ShowPopImage(url, headertext){
if (already_open>0){
// only refresh content
// alert("already open");
picturewin.load("iframe", url, headertext);
var target=window.frames["_iframe-"+picturewin.id].document.body
if (target) {
// this works in IE7 ...
// alert(target.scrollHeight + target.offsetHeight - target.clientHeight)
picturewin.setSize( (target.scrollWidth + target.offsetWidth - target.clientWidth),(target.scrollHeight + target.offsetHeight - target.clientHeight));
}
else {
//alert("not a object")
}
}
else {
// first time setup
already_open=1;
//alert("first time open");
picturewin=dhtmlwindow.open("PictureView", "iframe", url, headertext, "width=590px,height=350px,top=40px,left=300px,resize=1,scrolling=1,center=0")
picturewin.onclose=function(){already_open=0; return true;} // set our global variable to false to show window is no longer open
picturewin.setSize(300, 400);
picturewin.moveTo(320, 20);
picturewin.show();
}
}
While this works to some degree, it's limited to IE7 and only calculates the size of the iframe, not the whole popup. Some scrollbars occur on the first resize, but may be ok on the next... Seems to me the page content must be fully loaded before a resize can be triggered, and in this case also it needs several iterations.
Hope you can give me some ideas on how to do this correctly. Do I need to read the size of the main div in the widget, and if so how to reference it ?
Maybe the needed "ResizeToContentSize" code could be added to the Widget features in the future? You already wrote a better iframe resize script : http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm. Hope you can include this into the Widget.
Best regards
Frode Dragland