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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Overriding document.write, and then bringing it back

    My problem is that I want to override document.write, so external scripts use my personal function to save what they want to write, then when control is given back to me, I want to actually call the real document.write function to write it all at once.

    So this is what I coded:

    Code:
    <SCRIPT LANGUAGE="JavaScript1.1"><!--
    var pp_save_saveDW = "";
    var pp_save_trueDW = document.write;
    function pp_save_overDW()
    {
    	var args = pp_save_overDW.arguments;
    	if (args.length)
    		pp_save_saveDW += args[0];
    }
    document.write = pp_save_overDW;
    --></SCRIPT>
    
    <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript1.1"
    SRC="http://external.script.com/here.js"></SCRIPT>
    
    <SCRIPT LANGUAGE="JavaScript1.1"><!--
    pp_save_trueDW(pp_save_saveDW);
    --></SCRIPT>
    This does not seem to be working for me. I save the original document.write, then I override it. Then I try to call the original one, but it doesn't work. Is there a way to reset document.write to the correct, original function?

    ~Sean

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to override document.write, so external scripts use my personal function to save what they want to write, then when control is given back to me, I want to actually call the real document.write function to write it all at once.
    "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. "

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind... actually that code worked, the error was somewhere else. I got it to work.

    ~Sean


  •  

    Posting Permissions

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