Open Window in 1 function - check it in another

  • ShawnO
  • Newbie
  • Newbie
  • ShawnO
  • Posts: 6

Post 3+ Months Ago

Hey all,

I have this wierd window opening that I need to get done and it is bugging me extremely!! What happens is a customer enters a name in the 'Company' name field. When they click on the 'Check Name' link, it opens up a 3rd party website to check their name and if it already exists, etc... I don't have control over what is on the page that comes up, but I can control the info I send to it. (If that makes sence) Once the window pops up, I want to check if it is still open or not and when it closes, ask the user a question. Here's the code I am posting, but it seems that once the Window is opened in one function, the checking function can't determine whether it is still open or not...
Code: [ Select ]
function checkEnterpriseName() {
    myNewWindow = window.open('https://www.website.com/ent_lookup.asp?ename=CUSTOMERNAME&showAlt=True','zoomwindow','width=400, height=250, top=300, left=250, toolbar=0, menubar=0, location=0, status=0, scrollbars=0, resizable=0');
        checkWindow = setInterval('checkWindowOpen()', 1000);
}

function checkWindowOpen() {
    if (!(myNewWindow)) {
        alert ("Window closed");
        temp_confirm = confirm ("Click OK if the name is available!");
        if (temp_confirm) { alert ("True!"); }
        else {alert ("False!"); }
        clearInterval(checkWindow);
        }
    }
  1. function checkEnterpriseName() {
  2.     myNewWindow = window.open('https://www.website.com/ent_lookup.asp?ename=CUSTOMERNAME&showAlt=True','zoomwindow','width=400, height=250, top=300, left=250, toolbar=0, menubar=0, location=0, status=0, scrollbars=0, resizable=0');
  3.         checkWindow = setInterval('checkWindowOpen()', 1000);
  4. }
  5. function checkWindowOpen() {
  6.     if (!(myNewWindow)) {
  7.         alert ("Window closed");
  8.         temp_confirm = confirm ("Click OK if the name is available!");
  9.         if (temp_confirm) { alert ("True!"); }
  10.         else {alert ("False!"); }
  11.         clearInterval(checkWindow);
  12.         }
  13.     }

Any ideas?!!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

In the second line of checkWindowOpen what is
Code: [ Select ]
if (!(myNewWindow))
supposed to "not equal"? I think that's your problem...

Also...not sure about this...but I think you need to "prime the pump" so to speak on the "checkWindowOpen"

I think you need to call that function in addition to this code to start the loop...then checkEnterpriseName will keep the loop going.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Shawn0,

Welcome to OZZU. Good luck with your problem, but in the future please use the BBCode buttons for Code or PHP when posting code. Thanks.
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Code: [ Select ]
function RotateImage(){
    if (i <59)
    {
        i++;
    }
    else
    {
        i=0;
    }
    var alt = eval("image" + i + ".alt");
    document.rotator.alt = alt;
    var img = eval("image" + i + ".src");
    document.rotator.src = img;    
    setTimeout('RotateImage()',5000)
}
setTimeout('RotateImage()',5000)
  1. function RotateImage(){
  2.     if (i <59)
  3.     {
  4.         i++;
  5.     }
  6.     else
  7.     {
  8.         i=0;
  9.     }
  10.     var alt = eval("image" + i + ".alt");
  11.     document.rotator.alt = alt;
  12.     var img = eval("image" + i + ".src");
  13.     document.rotator.src = img;    
  14.     setTimeout('RotateImage()',5000)
  15. }
  16. setTimeout('RotateImage()',5000)


Here's something I did with a timer....see how...the time is extentiated in the function...but the loop is initiated outside the function...the function keeps the loop going. Maybe this isn't the easiest example to follow...but I wanted to show you what I meant by "prime the pump" in case that was a lil to redneck for ya :wink:
  • ShawnO
  • Newbie
  • Newbie
  • ShawnO
  • Posts: 6

Post 3+ Months Ago

It wasn't supposed to be that easy!!!! :)

Thanks a lot, it worked like a charm! I am partially bald at this point, but atleast I have some hair left!
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Give a man a fish he eats for a day...teach a man to fish...he eats for a lifetime!
  • ShawnO
  • Newbie
  • Newbie
  • ShawnO
  • Posts: 6

Post 3+ Months Ago

Everything works great now, except that I had all the code in the main page and when I went to move it to my external script page, it won't work. I know that the page is linked properly because I have code that fires for the FORM onSubmit function. Any ideas on this one.... Here is the link that I am using to call the function (this never changed from when it was internally scripted):

Code: [ Select ]
<a href="javascript: void CheckEnterpriseName();">Check Name</a>
(Hope I posted the code in the proper way for the bulletin board)

If I put the code back internally, it works fine. Move it to the external script it doesn't work. While I am at it, here is the link I am using for the external script:

Code: [ Select ]
<script language="javascript1.2" src="validateBlue.js"></script>


BTW, I am somewhat new to JS so if this is a really stupid question, please forgive me!!

Thanks,
Shawn

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 141 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.