View Full Version : Basic question - unable to find syntax documentation
05-11-2007, 02:24 PM
There is a bit of Java script that I am using, I find it works in Internet Explorer but not firefox, the code is :
(window.open("...", "foobar", "...") || window).focus();
I'm not sure what the double | character does, what the window keyword does when used after it, and I have spent some time looking for information on how that syntax works. Sorry for such a newbie question...
05-11-2007, 02:36 PM
what do you actually need?
05-11-2007, 02:41 PM
Again, I need to know what that syntax means. The use of the "||" operator, the use of the window keyword. Because it's not working in Firefox though it is in IE, and there is likely some minor syntax adjustment I need to make. And also, I just want to know what the syntax means so I can use it elsewhere if need be.
05-11-2007, 02:47 PM
Yes I understand that you don't know what || means, and I don't understand why you are using some code, which you don't know how it works.. :) that's why I am asking you what you need to do..
I think you need open some window... window.open("...", "foobar", "...") is okay lets say.. || is logical operator and it means OR. I can't say more until I will see all that code..
05-11-2007, 03:37 PM
I have a window.open statement that works fine, but the popup window wasn't always getting the focus. I googled around to find some solution, and this was the only one that worked. Basically if my window open statement (which works fine) is X, the syntax is (X||window).focus(). But it doesn't work in Firefox, so I figure it's some minor difference in how those browsers process the script, that is causing the problem. (For instance, yesterday I tracked down a problem to the fact that firefox allows spaces in the second parameter of window.open, but IE will skwawk about that syntax).
The actual code is :
"(window.open('" & moveUp & "Utilities/AVValues.aspx?ctl=" & e.PostBackValue & _
"','Values','width=400, height=300, menubar=yes, resizable=no')||window).focus();" & _
Where e.postbackvalue is a string, with 6-10 alphabetic characters and no spaces. right now moveUp is an empty string 90% of the time, and contains "../" the other 10%.
05-11-2007, 04:08 PM
Noone knows everything, so I don't find it strange..
I don't know, what about use that script just without that "||window" I mean just "menubar=yes, resizable=no').focus()";
05-11-2007, 05:05 PM
That works in IE too, I'll use that syntax as it's simpler. Still doesn't work in properly in Firefox. Thing is, the popup window is already open when this gets called, the second parameter in open() being the same, causes it to re-use the same window (which I want) and refresh its contents, but it stays behind the main window (which I don't want).
Thanks for the help.
p.s. not SURE if the second parameter being the same is what makes it grab the same window again, but it is in fact grabbing the same window, and it's a reasonable assumption. I could make the window a dialog box or something that would not let the user click on the main window till it was closed, but I don't particularly want that.
05-11-2007, 05:19 PM
It's really strange... anyway.. you can use div instead of popup if you want, just make a div with display:none, position:absolute, create a iframe within that div, load content into iframe, and when you will need to display the "popup" set display:block.. and some coordinates (left,top) it's a alternative ;)
05-11-2007, 09:06 PM
All that syntax means is that if the window.open succeeds it is equivalent to:
window.open("...", "foobar", "...").focus();
If the window.open fails it is equivalent to:
Basically it is testing the success of the open and setting the focus one of two ways based on whether the first OR second value is true. Since the second value (window) is always true it will always set one or the other.
05-11-2007, 09:49 PM
05-12-2007, 01:41 AM
Hope I helped,
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.