Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

popup question

Status
Not open for further replies.

VBmim

Programmer
Jun 25, 2001
361
BE
Hello

I have a webpage where the user can push a button to see a popup appear (the user then has to fill something in a textbox and press 'ok' or 'cancel'). This webpage is on a intranet, the only browser we are using is IE 6 (or IE 5.5).

At first I used a <div> to accomplish this (positioning the div in the middle of my page). This looked great until I noticed that the div would not show above a drop down box(<select>).

Apparently, there is no way I can set the z-index of the drop down box to set it behind my div (because a drop down box is a 'windowed' element).

I then used a popupbox:
Code:
var MimPopup = window.createPopup();
MimPopup.document.innerHTML = &quot;this is a popup&quot;;
MimPopup.document.style.backgroundColor = &quot;silver&quot;;

function OnclickButton
{
MimPopup.show(200,200,200,200)
}

This looked great! Positioned right above the dropdown list and all... until I noticed that, whenever I click on something outside the popup, the popup closes automaticly.

So, my questions are:

* Is there by any chance a possible way of positioning a div above a drop down box (all the other related questions said that it wasn't possible to do but I'm just asking)
* Is there a way I can prevent the popup to close automaticly when something is clicked.

Thanks in advance for the help

Greetz

VBMim
 
First Solution
When positioning the DIV over the SELECT change the select's style.display = &quot;none&quot; and back to = &quot;block&quot; when the DIV closes...

Second Solution
The pop window you created isn't closing, it is behind the larger window that has the main page on it. You can try to add an onFocus() event to the body tag. For instance, if you named the popWindow &quot;popWin&quot; then you could do something like this...

<script>
function checkFocus(){
if(popWin){
popWin.focus()
}
}
</script>

<body onFocus=&quot;checkFocus()&quot;>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Hello

Thanks for your fast response!

The first solution I would like to keep till the end (when nothing else has worked) because it is not a very esthetic solution.

I tried the second solution:

popWin.focus --> this gives an error: this method isn't supported by object

also, I declare my popWin variable globally (not in a function), so when the page loads, the popWin variable exists already and because of the checkFocus function it would show immediatly.

But I think it's the right direction to find a solution...

Greetz

Mim
 
Aha!

Found a very good solution for my problem:

Instead of using a div element (with other elements inside) I used an Iframe (pointing to a page with the needed elements). The Iframe positioned well above the select elements (probably because it is also a windowed element).
To make the IFrame look more like a popup and less like a window I set the frameborder to 0 and in the page I set the style of the body element to have a border.

Thanks for your time!

Greetz

VBmim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top