| 2 JS functions, 1 not working in NN A JS function not working in NN when combined with function window.close |
Isa71

msg:1491757 | 4:57 am on Mar 19, 2003 (gmt 0) | I am using the following function: <line breaks added to the feature string to prevent side scroll - tedster> <script language="Javascript"> function subwinopen(pageurl,winname){ pointer=window.open(pageurl,winname, "width="+(700)+",height="+(384)+",toolbar=yes,directories=yes, menubar=yes,status=yes,resizable=yes,location=yes,scrollbars=1,copyhistory=no"); pointer.focus(); return pointer; } </script> and it is working fine in both IE and NN. However, when I also use the window.close function it stops working (but the window.close function works fine)in NN! In IE, both functions work. I have the following in my code: <a href='javascript:;' OnClick='subwinopen("http://www.xxx.xx","",450,550);'>Click here to visit the xxx web site</a> </td> </tr> <tr> <td width="250" height="50" valign="top" align="right"><a href='javascript:;' OnClick='window.close();'>Close this window</a> </td> Any ideas what could be wrong? I am using NN 4.7. Cheers :-)Isa [edited by: tedster at 6:48 am (utc) on Mar. 19, 2003]
|
DrDoc

msg:1491758 | 8:12 am on Mar 19, 2003 (gmt 0) | window.close only works if the window was opened by JavaScript...
|
Isa71

msg:1491759 | 1:02 pm on Mar 19, 2003 (gmt 0) | DrDoc, the window where I use the two functions is opened with Javascript (in fact it is opened with the same subwinopen function). And the window.close function is the one that works. It is the subwinopen function that doesn't. /Isa
|
Gizmare

msg:1491760 | 7:04 pm on Mar 19, 2003 (gmt 0) | ISa71, Change this line: <a href='javascript:;' OnClick='subwinopen("http://www.xxx.xx","",450,550);'> to <a href='javascript:subwinopen("http://www.xxx.xx","",450,550);'> or this may work? <a href='javascript:;' OnClick='subwinopen("http://www.xxx.xx","",450,550);return false;'> and this line: <a href='javascript:;' OnClick='window.close();'> to <a href="JavaScript:window.close()">
|
DrDoc

msg:1491761 | 9:39 pm on Mar 19, 2003 (gmt 0) | Nicely spotted, Gizmare! Yep, I'd have to second that suggestion. It should solve your problem :)
|
Isa71

msg:1491762 | 1:16 am on Mar 20, 2003 (gmt 0) | Thanks Gizmare and DrDoc. However, it has not quite solved the problem. What happens now (with my old code or with your suggestion) is that the web site specified in the function subwinopen opens, but in the same window. This leads me to believe that NN has a problem opening another window from a window that was already opened with JavaScript. Could this be? The window.close function, as before, works fine. Any ideas? Cheers :-)Isa
|
DrDoc

msg:1491763 | 6:09 am on Mar 20, 2003 (gmt 0) | Does the new window have a different name than the first one? If not, it will open in the same window...
|
Gizmare

msg:1491764 | 10:59 pm on Mar 20, 2003 (gmt 0) | Isa71, Here is the code I use to accomplish this task. It works with NN4.7 , NN6+ and IE4+. function shrinkBrowser(url){ window.open(url,"","width=400,height=450,scrollbars=no,toolbar=no,status=no,resizable=no"); } <a href="JavaScript:shrinkBrowser('/Virtual-Tours/top_deck.htm');">
|
tedster

msg:1491765 | 12:10 am on Mar 21, 2003 (gmt 0) | The subwinopen() function you're using uses two variables - url and winname. But you're apparently not passing an explicit "winname" variable when you call the function. Just do that, and use a different winname each time you want a separate new window to open. subwinopen("http://www.xxx.xx","window1") Also, I notice that the function you've defined already sets the size of the new window as 700x384. You could turn height and width into variables and pass them as parameters whenever you call the function, but you can't expect to override them. For some examples, see the Generic Javascript [webmasterworld.com] thread, message number 4.
|
Isa71

msg:1491766 | 12:29 am on Mar 21, 2003 (gmt 0) | Thanks DrDoc, Gizmare and tedster! Of course I had forgotten to name the window. I guess since it was working perfectly fine in IE, and I had used the same function on another page where there was only one window to open, I just forgot about it. Thanks for reminding my brain to start thinking again... ;-)! Isa
|
|
|