Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Basic question - unable to find syntax documentation

    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...

  • #2
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what do you actually need?
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #5
    New to the CF scene
    Join Date
    May 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know that "||" means a logical OR in just about any other syntax I've seen it in. It seems to do some kind of object dereferencing in this case, but the syntax is strange to me. I am learning this on-the-job. I know you probably find it strange that I could be employed to work without being completely knowledgable in every respect to every aspect of programming Javascript. I have worked in IT for 25 years so they must think I can pick it up as I go (and I'm glad for the chance to update my skills). THAT'S why I'm using code where I have an idea what it is doing, but have some questions on the specifics. (In a year from now when the contract is over I'll have learned plenty, and likely look at what I designed, and how some things were structured, and cringe in embarrassment, right now the focus is just getting something done.)

    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 :

    popupScript = "<script language='javascript'>" & _
    "(window.open('" & moveUp & "Utilities/AVValues.aspx?ctl=" & e.PostBackValue & _
    "','Values','width=400, height=300, menubar=yes, resizable=no')||window).focus();" & _
    "</script>"
    Page.RegisterClientScriptBlock("AVValuesPopupScript", popupScript)

    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%.

  • #6
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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()";
    Last edited by smalldog; 05-11-2007 at 03:11 PM.
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #7
    New to the CF scene
    Join Date
    May 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #9
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,453
    Thanks
    0
    Thanked 632 Times in 622 Posts
    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:

    window.focus();

    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.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,946
    Thanks
    0
    Thanked 236 Times in 233 Posts
    If it's not working in Firefox, then check the Javascript Console to see if it throws any error.

  • #11
    Regular Coder kosstr12's Avatar
    Join Date
    Apr 2007
    Location
    Woodstock, Georgia
    Posts
    428
    Thanks
    7
    Thanked 5 Times in 5 Posts
    I thought that you were wondering why you had to include window. Its because there are so many different parts of javascript that they split them up by using different categories like:
    Math.
    Window.
    And others

    Hope I helped,
    kosstr12


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •