Before you get all abrasive, this is not truly OT, but close enough to warrant the disclaimer. I am using perl to write the javascript based on certain conditions. What I want to know is can I write something like the following pseudocode: document.form.description_box.focus() unless window.new.hasFocus;

I've got a form that grabs focus in a text input field. When you submit the form it saves the info in the database and it returns to the same page that you come from. New complications have come up so that I have to pop-up a window to do extra tasks in specific cases. So I want to keep from giving the focus back to the text input field when it reloads the form in the main window. I have added: onload="self.focus();" into the new window, but that only avoids the problem temporarily by creating a race condition that is favorable to the new window getting focus. But what happens if the other script takes longer to reload the main window and grabs focus after the new one? That's why I want to add code to the main window in the event that a new window exists.

Oh yeah, the form must be submitted in order to have proper values available to the new window. Otherwise, I'd just hold off on executing the form until I had done what I needed in the new window.

ALL HAIL BRAK!!!


In reply to OT:A javascript problem. by PsychoSpunk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.