Client Side Script window.open

Discussion in 'ASP .Net' started by Sam, Nov 15, 2006.

  1. Sam

    Sam Guest

    Does anyone know if I can write a whole webpage content stored in a variable
    to a popup window? The variable that I'm talking about is a string variable
    which has its content generated by an aspx page). Now if I write the content
    of this variable to a file (let's say mypage.htm) and open it using
    window.open('mypage.htm',name,attrib);" then everything works just fine. The
    problem is that I have to generate the content of this page on fly to output
    to a new popup window. Could someone give me a hand? Thank you

    Regards,

    Sam

    Below is what I have in my event handler which it keeps giving me different
    kind of errors and a window will popup. Now if take out this line sScript &=
    osb, everything would look fine



    Dim sScript As String
    sScript &= "<script language=javascript>"
    sScript &= "var name = 'mypopup';"
    sScript &= "var attrib =
    'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=250,height=250';"
    sScript &= "popupwin = window.open('',name,attrib);"
    sScript &= "popupwin.document.open();"

    sScript &= "popupwin.document.write("
    sScript &= """"
    sScript &= osb
    sScript &= """"
    sScript &= ");"

    sScript &= "</script>"

    Response.Write(sScript)
    Sam, Nov 15, 2006
    #1
    1. Advertising

  2. Hi,

    Sam wrote:
    > Does anyone know if I can write a whole webpage content stored in a variable
    > to a popup window? The variable that I'm talking about is a string variable
    > which has its content generated by an aspx page). Now if I write the content
    > of this variable to a file (let's say mypage.htm) and open it using
    > window.open('mypage.htm',name,attrib);" then everything works just fine. The
    > problem is that I have to generate the content of this page on fly to output
    > to a new popup window. Could someone give me a hand? Thank you
    >
    > Regards,
    >
    > Sam


    You can if you use JavaScript.

    Once you open the window, you can use the reference you get to get the
    pop-up's document and write to it:

    var strHtml = "Hello world<br />How are you?";

    var wPopUp = window.open( "", "wPopUp", attrib );
    wPopUp.document.writeln( strHtml );
    wPopUp.document.close();

    HTH,
    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch
    Laurent Bugnion, Nov 16, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shawn Mehaffie
    Replies:
    4
    Views:
    643
    Shawn Mehaffie
    Jan 22, 2004
  2. Magnus Blomberg
    Replies:
    3
    Views:
    694
    Magnus Blomberg
    Apr 14, 2005
  3. Boss302
    Replies:
    0
    Views:
    1,006
    Boss302
    Nov 21, 2006
  4. Bogdan
    Replies:
    2
    Views:
    631
    Bogdan
    Jun 9, 2008
  5. Zoe Hart
    Replies:
    1
    Views:
    337
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page