Aaron Bennington

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromAaron Bennington
ToMe
SubjectPerfect popups question and help :-)
Date10 May 2004 17:59
I am trying to implement the perfect popup on a window that pops up but
needs to be resized after it pops up like Resizing the inside of the
current window you speak of at the end of the article. I am not very good
with javascript and am having a problem implementing the script.

I created a new html doc and placed this javascript in the head.

function resizeWinTo( idOfDiv ) {
  var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }
  var oW = oH.clip ? oH.clip.width : oH.offsetWidth;
  var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
  var x = window; x.resizeTo( oW + 200, oH + 200 );
  var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
  if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
  else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
  else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
  if( window.opera && !document.childNodes ) { myW += 16; }
  x.resizeTo( oW + ( ( oW + 200 ) - myW ), oH + ( (oH + 200 ) - myH ) );
}


but it does not seam to work. Am I missing something. Also I have a div tag
that for testing I named idOfDiv.

I am not specifying a height or anything else on the div because I do not
know what the width of the table in the div might be. 

Do you have an example of this in action I could see the code on an html
page or could you send me an example html page with this?

Thanks and love the scripts and lessons!

Aaron
FromMe
ToAaron Bennington
SubjectRe: Perfect popups question and help :-)
Date11 May 2004 15:47
Attachmenta working version of the script
Aaron,

OK, firstly, 3 points about the code you sent me.
You need to actually call the function.
You will also need to include the referencing function.
Also, idOfDiv is a variable, not a name, when you call the function, you
need to pass it the name of the div that you are using.

Because you are not forcing a certain width, the table will reformat very
strangely, which will really confuse the script. As it resizes the first
time, the table changes size as well. The script does not know this, so you
need to resample the height and width of the div before you resize again.

Also, as the page may start with scrollbars - especially if the window
starts small, and the table readjustments may change that (unlike when the
width is fixed), I feel it is a good idea to resize the window to its
maximum available space first, even if it is not always necessary.

I also found that opera 7 needs you to set the padding on the body tag to 0
if you do not force the width of the containing div tag.
<body onload="resizeWinTo('mydiv');" style="padding:0;">

I have attached an example. Hope it helps


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromAaron Bennington
ToMe
SubjectRe: Perfect popups question and help :-)
Date11 May 2004 15:53
WOW!!!! All I can say is WOW!!! You are the best!!!! This works
great!!!!!

I have never had such a quick response and in such detail by a company
or individual before! This and you are incredible!!! 

THANKS again!!!
Aaron
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.