locked
Pop up a new windows and get a value back? RRS feed

  • Question

  • User1671288766 posted

    Hi!

     I want to open up a new window on the client side. OK, I can realize this with a target="_blank"-Hyperlink. But i want to get (at least) one value back from this window, based on the user input and actions. How to realize this?

     
    regards,
    nodh
     

    Friday, December 1, 2006 12:20 PM

Answers

  • User1880055189 posted

    add a hidden field to the parent page then in the child window you could do something like...

    window.opener.document.getElementById('hiddenfield').value = 'whatever';

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 1, 2006 5:38 PM

All replies

  • User1880055189 posted

    add a hidden field to the parent page then in the child window you could do something like...

    window.opener.document.getElementById('hiddenfield').value = 'whatever';

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 1, 2006 5:38 PM
  • User1671288766 posted
    OK, and to get a value into the Poup it’s the same method, I guess?
    Saturday, December 2, 2006 6:15 AM
  • User798903548 posted

    You can pass a value to the child window with a QueryString:
     NewPage.aspx?SomeValue1=value1&SomeValue2=value2

    Or directly:
     <script language=JavaScript>
     var windowRef = window.Open(...)
     windowRef.document.getElementById('elementID').value = value1;
     </script>

    NC...

     

    Saturday, December 2, 2006 11:41 AM
  • User1671288766 posted
    Or directly:

     <script language=JavaScript>
     var windowRef = window.Open(...)
     windowRef.document.getElementById('elementID').value = value1;
     </script>

    The value passed to the popup depends on an user input in a texfield.
    So I tried this, but Firefox is complaining "windowRef.document.getElementById("txNummer") has no properties" [:S]

    It’s executed as ClientClick on a LinkButton, or should I use an other component? 

    Sunday, December 3, 2006 7:04 AM
  • User1880055189 posted

    I wonder if it is because the window has not had a chance to load the content yet?

    if you alert windowRef.document.getElementById('elementID').value does it give you an undefined?

    Sunday, December 3, 2006 3:30 PM
  • User798903548 posted

    I think that SuperGhost hit it right on the head! Try:

    <script language=JavaScript>
    var windowRef = window.Open(...)
    window.setTimeout('setChildWindow()', 10);

    function setChildWindow()
    {
     windowRef.document.getElementById('elementID').value = value1;
    }
    </script>

    You might have to up the delay. I set it at 10 milliseconds to give the child window a chance to fully load, but you might need more.

    NC...

    Monday, December 4, 2006 10:30 AM
  • User307688573 posted

    the best way is to use the opener object javascript.

    first you should make a childWindowCallback() function in your parent window to do anything you have to do when the child window is finished.

    second, open your child window: var chwin = window.open("url", options);

    3rd, when you are done wiht your child window , you can do opener.childWindowCallback() before closing.

    (i am not sure if this is IE-only, if so, you are always welcomed to push the parent window as a variable into child window like: chwin.parentWindow = this;

    Monday, December 4, 2006 3:09 PM
  • User798903548 posted


    the best way is to use the opener object javascript.

    Yes, that is the best way. The poster did ask for a way to set a variable from the parent however, and that's what I tried to provide him.


    (i am not sure if this is IE-only, if so, you are always welcomed to push the parent window as a variable into child window like: chwin.parentWindow = this;

    The window.opener property should be available on any browser.

    NC...

    Tuesday, December 5, 2006 7:07 AM