View Full Version : DHTML Window widget (v1.1) - window 4 get to stay open until closed manually

02-25-2011, 08:19 PM
1) Script Title: DHTML Window widget (v1.1) - Window 4 - get to stay open until closed manually?

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem: Hi - I'm new to the forum. I have installed the DHTML window and would like to find out if it is possible to have the window KEEP OPEN until it is clicked closed by the user.

In my use, I have the window opening by a click (I don't have it popping up up automatically). Please visit http:// www.hydrowest.ca/index.html and click on Vancouver "magnifying glass" map graphic to view in action. What I'd like is to see if once that vancouver map is clicked open, if I can keep it alive on the page while people click and navigate out of the index (when they are looking at the individual projects) and back to the index page to look at the next project in that map. As you see right now, it's inconvenient to have to keep opening the map again each time.

I realize that a possible solution would be to have the project pages open in new windows, but I am hoping not to have to do that (may be confusing for some people that are using the website)

Thanks for your help!

03-02-2011, 06:53 AM
Try this. Use a session only cookie to indicate a DHTML window is open once that's the case. Here's an example, with the interesting parts highlighted in red:

<script type="text/javascript">

function openwindow(){
var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://images.google.com/", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")

if (document.cookie.indexOf("googlewin")!=-1) //if "googlewin" DHTML window has been opened previously within this browser session
openwindow() //open it again when the page loads


<a href="#" onClick="openwindow(); return false">Open DHTML window "googlewin"</a>

The above link when clicked on calls openwindow(), an arbitrary function that in turn opens a DHTML window using the documented syntax and assigns the result to the variable "googlewin". The code in red then uses JavaScript cookies to indicate that this window has been open. Following this function is a check for whether this DHTML window was previously open (within the current browser session), and if so, automatically open the window again when the page loads, by calling openwindow().

You should be able to adapt the above example to work for your own code.