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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Location
    NJ - #29 if you must know
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Just found something of interest....

    I had posted a question about a year ago, wanting to know
    how I could "transfer" a function from one program to a new
    window with the document.write..

    What I was trying to do was have one window create a new
    window, functions and all, This new window could then be
    saved to the hard drive for future running locally, which was
    why I couldn't have the new window run the functions from
    the original window (because after it's saved, only the new
    window was saved).

    Initially, I chose to duplicate the functions on in the originating
    window, and the the other was just "data" to be written to the
    new window as javascript functions (which took up some room).

    But by accident, I found something today. that I haven't yet
    fully explored that might solve my problem.

    I had a function that computed a number, and returned that number.
    so say:

    function testfunct() {
    var somenum=5;
    return somenum;
    }

    OK...now for what amazed me.

    put in this:

    alert(testfunct);
    So...

    If I wanted to transplant a function I should in essence be able
    to do:

    var func1=testfunct;

    then loop through func1, document writing each line.

    Untested at present....has anyone done this?
    I didn't have time to test the theory, and won't for a couple days

    George

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script type="text/javascript">
    <!--

    function hello(message){
    message = "hello";
    }
    var func1 = hello;
    document.writeln(func1);

    //-->
    </script>


    <script type="text/javascript">
    <!--

    function hello(message){
    message = "hello";
    }
    var func1 = hello;
    var newWin = window.open("","","");
    newWin.document.open();
    newWin.document.writeln(func1);
    newWin.document.close();

    //-->
    </script>





    -james
    Last edited by jamescover; 09-29-2004 at 02:44 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "


  •  

    Posting Permissions

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