Prev: ANNC: qooxlisp 0.1: Driving Miss qooxdoo (from Common Lisp)
Next: FAQ Topic - How do I generate a random integer from 1 to n? (2010-05-31)
From: Jonathan Atkinson on 30 May 2010 18:13 Hi, I have a very simple function to open a help window: function help_window(url, width, height) { help_window = open('/Help/'+url, 'help_window','toolbar=0,directory=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+width +',height='+height); help_window.focus(); }
From: Jonathan Atkinson on 30 May 2010 18:16 Sorry, my message was truncated. Anyway, the function is supposed to open a pop-up window, which it does. But it only seems to work once. If you close the pop-up window, then click the link again, nothing happens. I got the same result in both Safari and Google Chrome. Is there some code I need to add to check if a window has been previously opened and closed? Thanks in advance for your time. Regards, Jonathan
From: Martin on 30 May 2010 18:22 On 30 May, 23:16, Jonathan Atkinson <atkinsons...(a)gmail.com> wrote: > Sorry, my message was truncated. > > Anyway, the function is supposed to open a pop-up window, which it > does. But it only seems to work once. If you close the pop-up window, > then click the link again, nothing happens. I got the same result in > both Safari and Google Chrome. > > Is there some code I need to add to check if a window has been > previously opened and closed? > > Thanks in advance for your time. > > Regards, > Jonathan Looks like the function overwrites itself when it is first executed. After being executed, help_window is no longer your function but a handle to the pop-up window which was opened. warwound.
From: Thomas 'PointedEars' Lahn on 30 May 2010 20:17
Martin wrote: > Jonathan Atkinson wrote: >> Anyway, the function is supposed to open a pop-up window, which it >> does. But it only seems to work once. If you close the pop-up window, >> then click the link again, nothing happens. I got the same result in >> both Safari and Google Chrome. >> >> Is there some code I need to add to check if a window has been >> previously opened and closed? Yes, it is in the FAQ: <http://jibbering.com/faq/#posting> > Looks like the function overwrites itself when it is first executed. > > After being executed, help_window is no longer your function but a > handle to the pop-up window which was opened. Exactly, that is correct. A solution is to declare a differently named variable and assign to that variable instead; the variable should be global if the Window instance is reused, otherwise local. It should also be window.open(...), and "resizable[=1]" ("=1" is optional). It is possible that none of the other settings take effect. Be extra careful with setting `width' and `height', and feature-test the focus() method before you call it (search for "isMethod OR isHostMethod", maybe you even need to catch exceptions). <https://developer.mozilla.org/en/DOM/window.open> PointedEars -- realism: HTML 4.01 Strict evangelism: XHTML 1.0 Strict madness: XHTML 1.1 as application/xhtml+xml -- Bjoern Hoehrmann |