sh#te, I'm stuck!

Results 1 to 5 of 5

Thread: sh#te, I'm stuck!

  1. #1
    fl1rt Guest

    Default sh#te, I'm stuck!

    I&#039ve spent so long doing ASP that I think I&#039ve forgotten Javascript!<BR>(this posting is duplicated on the JScript board too, where it should be, but most of the cool guys(and girls!) hang out here!)<BR><BR>____________________________________ _____________________<BR><BR>is it possible to call a javascript function from a main window to a child &#124 popup window where the function is stored and return the result to the main window?<BR><BR>communicating the other way around should be easy enough with the window.opener command<BR><BR>eg:<BR>main.asp.....<BR>&#060;img src="whatever.gif" onClick="javascript:window.popup.cMB_Button()" height=18 width=18 alt="" border=0&#062;<BR><BR>where clicking the image would call the function "cMB_Button()" in the separate pop-up window.<BR> <BR>any takers ? or is this impossible?<BR>obviously the window.pop syntax is incorrect and I can&#039t locate any reference for such a task.

  2. #2
    Join Date
    Dec 1969

    Default RE: sh#te, I'm stuck!

    You almost have it.<BR><BR>You just have to "remember" the popup window when you open it.<BR><BR>SO:<BR><BR>&#060;SCRIPT&#062;<BR>var thePopUp; // make sure this is at global level<BR><BR>thePopUp = ... ); // so even if this isn&#039t it works<BR><BR>...<BR>var theVal = thePopUp.functionName(...);<BR><BR>The best place for JavaScript questions is (my opinion) and the JavaScript FAQ.<BR><BR>For example, this page isn&#039t a direct answer to your question, but it&#039s pretty close:<BR><BR><BR>One caution: If you create the window and then try to access the function before the popup is completely created, you&#039ll get an error. One way to fix that is have the child window set a value back in the opener&#039s window and wait for that to be valid. With all the version 4 browsers, "window.opener" refers to the parent window, so that&#039s easy to do. See<BR><BR>for an example.<BR><BR><BR>

  3. #3
    fl1rt Guest

    Default RE: sh#te, I'm stuck!

    I could have sworn I had tried that method too and looks a pretty good resource<BR>(weird, how I&#039ve never came across that site before ???hmm)<BR><BR>I have found an alternative solution, which is to call a popup open function from the main page with a set of querystring data that is passed to the popup used to generate the necessary "secure" javascript and then pass the javascript results back to the opener and close the popup in turn. It appears to work pretty well, though I&#039ve yet to convert all my functions to this format.<BR><BR>the whole reason for doing this is to keep the javascript away from prying eyes, once the popup has the appropriate saving methods removed from it.<BR><BR>can anyone see any security issues with this in terms of keeping the javascripts secure during development ?

  4. #4
    jason Guest

    Default RE: sh#te, I'm stuck!

    take a look back in the other forum, i just answered u<BR><BR>jason

  5. #5
    fl1rt Guest

    Default RE: sh#te, I'm stuck!

    cheers for that.<BR>but I used a different method above to communicate between the 2 windows. At least I now know the "proper" way too.

Posting Permissions

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