SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast erickkz's Avatar
    Join Date
    Dec 2005
    Location
    Earth
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy javascript clear document

    Hi everyone!

    I'm trying to view some content in a window but each time I run the function
    the content adds to the last content.
    HTML Code:
    function view(){
    var  viewstate=window.open('','view','height=400,width=600,top=0,left=0,toolbar=0,scrollbars=auto,location=0,statusbar=0,menubar=0,resizable=1');
    viewstate.document.open();
    viewstate.document.clear();
    with(viewstate.document){
        write('<html>\n<head><title>View variables</title></head>\n\n<body>');
    							
        for(uk=0; uk<10; uk++){
           for(mk=0; mk<10; mk++)
              auxstring=auxstring+auxarray[uk][mk]+' ';	
              auxstring=auxstring+'<br>';
    }
    write(auxstring);
    write('</body>\n</html>');
    }
    viewstate.document.close();
    }
    the line viewstate.document.clear(); seems doesn't work. any idea?

    SOLVED

    HTML Code:
    function view(){
    var  viewstate=window.open('','view','height=400,width=600,top=0,left=0,toolbar=0,scrollbars=auto,location=0,statusbar=0,menubar=0,resizable=1');
    viewstate.document.open();
    with(viewstate.document){
        write('<html>\n<head><title>View variables</title></head>\n\n<body>');
        auxstring='';					
        for(uk=0; uk<10; uk++){
           for(mk=0; mk<10; mk++)
              auxstring=auxstring+auxarray[uk][mk]+' ';	
              auxstring=auxstring+'<br>';
    }
    write(auxstring);
    write('</body>\n</html>');
    }
    viewstate.document.close();

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a tip, don't use with(){}, it's slow as hell and even evil

  3. #3
    SitePoint Member
    Join Date
    May 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi erickkz,
    I just wanted to know how you solved this problem ?.

    Thanks,
    Amit


Bookmarks

Posting Permissions

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