i have created a transparent popup with a text box.but the transparent window is of fixed size. i want to increase size of transparent popUp according to html page on which show popUp.
i have used this script :
http://www.pat-burt.com/csspopup.js
style used is:
#blanket {
background-color:#111;
opacity: 0.65;
filter:alpha(opacity=65);
position:absolute;
z-index: 9001;
top:0px;
left:0px;
width:100%;
}
#popUpDiv {
position:absolute;
background-color:#eeeeee;
width:300px;
height:300px;
z-index: 9002;
}
i am using this script for onload() event
please help and provide some advice or reference.
Thanks to all
The script needs to be re-written to allow for a dynamic popupDiv size, be it a percentage or simply a larger fixed value.
The lines causing problems are:
and
In my revised script I changed said lines to:
and
You can use element.offsetHeight and element.offsetWidth to get the height and width of an element, respectively. Thing is, the element needs to be displayed in order to have a height and width. That’s why you have to display it first if it’s not displayed, take the measurement needed, and quickly hide it again. It will occur fast enough such that the user will not notice.
Once you have that, then the CSS can become (for example):
EDIT: I’ve updated the code to take into account window resizing. I’ve added a function called window_resize which gets called when the window is resized while the popUp is being displayed. I’ve also decided to play nice and store any existing onresize callback before overwriting it, call it after my window_resize function executes, and restore it when the popup is no longer being displayed.
I’ve also updated the example at http://so.savantcoding.com/csspopup/. Again the the javascript is viewable at http://so.savantcoding.com/csspopup/csspopup.js