Click to See Complete Forum and Search --> : window.createPopup() size
Webskater
10-21-2003, 10:57 AM
I am using window.createPopup() to open little popup windows with help tips inside them. Although I have scroll bars on them so they can cope with displaying different amounts of data, I would like to dynamically resize them to suit what they are displaying.
Is this possible?
Thanks for any help.
requestcode
10-21-2003, 12:36 PM
What is window.createPopup()? Is that a script that was created for you? If it is can we see it?
fredmv
10-21-2003, 12:54 PM
I would strongly recommend against using this method as it is IE-only. However, you may find this (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/createpopup.asp) helpful.
Webskater
10-21-2003, 02:18 PM
window.createPopup is a Microsoft dhtml thing that allows you to create popup windows with features such as scroll bars, borders etc but no chrome. Thanks for the link to the ms site - I am already pretty familiar with the concept - but what I really need to find out is if they can resize dynamically to fit the content.
As far as them only being IE compatible, I am less and less interested in developing for people who, because of some anti Microsoft feeling, are unwilling to put a free piece of software on their computer which allows them to enjoy a much more sophisticated application interface.
nkaisare
10-21-2003, 02:55 PM
Originally posted by Webskater
As far as them only being IE compatible, I am less and less interested in developing for people who, because of some anti Microsoft feeling, are unwilling to put a free piece of software on their computer which allows them to enjoy a much more sophisticated application interface.
You probably haven't bothered to take a look at other browsers like Opera, Mozilla, Firebird etc. IE comes installed on the PC with Windows. In all probability, people using browsers other than IE do so as a choice because these browsers happen to provide more than IE, are customizable and have much lesser security flaws.
I am not trying to undermine IE, which is a decent browser; but merely on the merit of being a browser that 80 to 90% of PC owners use does not make it the most advanced. Not all people using browsers other than IE are anti-MS.
(BTW, some of your IE-specific functions may fail in a very-much-Microsoft IE/Mac.)
For your information, IE6 is the last free browser from MS. While other browsers will continue to remain free (or at least thats what we hope), MS is planning to integrate IE with Win-Longhorn, and will no longer support the standalone browser.
If an equally simple, standards compliant method exists, why use a browser-specific method?
TomDenver
10-21-2003, 03:06 PM
Coding for IE only is fine for your personal sites, but if you work for someone you're going to have to code for many browsers usually, at the very least IE6 and NN7, and usually more than that.
I've been pretty lazy about this myself. I make stuff work in the 2 I mentioned. I know that Mozilla is very similar to NN7, so I think that most stuff that works in NN7 will usually work in Mozilla. Opera I have no clue about.
As for people who have JavaScript turned off.....I tend to ignore this demographic.
nkaisare
10-21-2003, 03:11 PM
Well, you may want to code "independent of the browser" by sticking to the W3C recommendations, and then implement browser-specific hacks to make them work in specific browsers of your interest. That kind of development, at least to me, seems more robust than "cross-browser" development.
As for people who have JavaScript turned off.....I tend to ignore this demographic.
Instead, you can tweak your javascript a little to ensure they aren't ignored. You can do more critical tasks (such as form submission) at non-js level.
Remember, the Sydney Olympic committee was successfully sued because their site was inaccessible in non-javascript browser. Personal sites are a lot different story, though
TomDenver
10-21-2003, 04:42 PM
I'm curious, why do people turn off JavaScript anyway? The only answer I can think of is that it works as a primitive pop up blocker by turning it off.
Webskater
10-22-2003, 03:59 AM
I am curious about the Sydney Olympic thing - what kind of a nutty world lets someone be sued for providing something that some people cannot use. Should escalator manufacturers be sued for making something a wheelchair user cannot use. Should Mercedes be sued for making cars I cannot afford? Should people who make spectacles be sued because people who are blind cannot use them.
I develop sites for business users - I say to them "to make my application as easy to use as possible - and to give it enhanced useability features - you need to be running IE5.5 or later to use it - take it or leave it - if you don't want to use my application because you insist on a different or older browser - thats your choice.
Anyway, what about popup windows created using window.createPopup - can they be dynamically re-sized to suit their content?
daviddavidson
08-18-2004, 06:28 PM
Wow, that thread degraded in a hurry. To answer the original question, place the popup's contents into a div with the visibility style set to hidden and then open the popup window with a height of the div's offsetHeight. You cannot resize a popup window after it's displayed. Using a div causes IE to render the text (even though it's hidden) and allows you to access the size of that text. Set the div's width to the standard width for your popups, or use the expression (dynamic properties) syntax to set the width to something like half of the body's clientWidth. The div's offsetHeight will automatically adjust to the wrapped content and always provide you with an accurate number. You can even use the innerHTML property to populate your popup window on-the-fly and use one popup object for all of your popups. Remember to add some padding to your popup's height if it's displaying a border.
Originally posted by TomDenver
I'm curious, why do people turn off JavaScript anyway? The only answer I can think of is that it works as a primitive pop up blocker by turning it off.
JS can transport viruses and spyware. this is more so using IE than anything else, because JScript (M$'s implementation of JS) can be used to code the OS. The mechanism for doing this is called ActiveX.
If wanted to i could code a JS to delete important files from your PC, thus disabling it. I know of several nasty (tho seeminly innocuous methods) to do this, and you as a user would be none the wiser till your PC failed. it's much easier than you think.
that's why I surf (even when using FF) with JS turned off.
eidentity
03-02-2005, 01:01 PM
All the Political stuff aside, I see what you mean about the sizing, I realize this thread is a year old, but here is a compartmentalized take off on the microsoft example that autosizes the PopUp, hope somebody can use this. NOTE:: take the space out of the '  ;' so it works correctly...
<script><!--//
var myPopup = window.createPopup();
function PopUp(textMessage)
{
// EXAMPLE :: onmouseover="PopUp('Some Message');" onmouseout="myPopup.hide();"
var myPopBody = myPopup.document.body;
var myPopupDiv = document.createElement('DIV');
var myPopupWidth = 0;
var myPopupHeight; = 0;
var myPopupOffSet = 20;
var myPopupXBuffer = 4;
var myPopupYBuffer = 4;
var modifiedtextMessage = new String(textMessage).replace(/ /gi,'  ;');
//Set Up Da' Pop Up
with(myPopBody)
{
//General Appearance
style.textAlign = 'center';
style.verticalAlign = 'middle';
style.backgroundColor = 'lightyellow';
style.border = 'solid black 1px';
//Font Settings
style.fontFamily = 'Arial';
style.fontWeight = 500;
style.fontStyle = 'normal';
style.fontSize = '8pt';
style.color = '#004080';
}
//Determine Actual Width
with(myPopupDiv)
{
id = 'myPopupDiv';
style.position = 'absolute';
style.visibility = 'hidden';
style.fontFamily = myPopBody.style.fontFamily;
style.fontWeight = myPopBody.style.fontWeight;
style.fontSize = myPopBody.style.fontSize;
style.fontStyle = myPopBody.style.fontStyle;
innerHTML = modifiedtextMessage;
}
this.document.body.appendChild(myPopupDiv);
//Display Da' Pop Up
myPopupWidth = (myPopupDiv.clientWidth + myPopupXBuffer)
myPopupHeight = (myPopupDiv.clientHeight + myPopupYBuffer);
myPopBody.innerHTML = modifiedtextMessage;
myPopup.show((window.event.x + myPopupOffSet), window.event.y, myPopupWidth, myPopupHeight, this.document.body);
}
//--></script>