how to open a web form in new IE window on clicking hyperlink with NO scrollbars, status bar and too

Discussion in 'ASP .Net' started by loga123, Jun 7, 2006.

  1. loga123

    loga123 Guest

    I am using asp .net 2.0. I have a hyperlink asp control on my web page
    page1.aspx.
    On clicking this hyper;link, I would like to open page2.aspx (which is
    in the same web application) in a new IE window without scrollbars,
    status bar, tool bar and with specified height and width.
    Can it be done on "onload" event of the page2.aspx in javascript?
     
    loga123, Jun 7, 2006
    #1
    1. Advertising

  2. Re: how to open a web form in new IE window on clicking hyperlinkwith NO scrollbars, status bar and toolbar?

    Hi,

    Eliyahu Goldin wrote:
    > You need to open the page with a javascript call to window.showModalDialog
    > function. Look up the MSDN info on this function, you will find how to
    > specify the scrollbars and other parameters.
    >
    > For the hyperlink, specify url as javascript:showModalDialog(...)
    >
    > Eliyahu


    Using javascript: is a bad idea and can lead to problems on some
    platforms. It's much more elegant to use the following construct:

    <a href="nojs.html" onclick="doSomething();return false;">Click</a>

    The advantage of this is that the onclick even won't be executed if
    JavaScript is not present or deactivated, and the link will degrade
    gracefully and lead the use to a page (nojs.html) explaining why the
    experience would be better with JavaScript.

    Besides, showModalDialog is IE only, so using window.open() with a set
    of chosen features is a better choice. Since the OP doesn't need the
    window to stay in front (modal), the window.open method is enough.

    More info here:
    http://developer.mozilla.org/en/docs/DOM:window.open
    and
    http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp

    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, Jun 7, 2006
    #2
    1. Advertising

  3. Re: how to open a web form in new IE window on clicking hyperlinkwith NO scrollbars, status bar and toolbar?

    Hi,

    loga123 wrote:
    > I am using asp .net 2.0. I have a hyperlink asp control on my web page
    > page1.aspx.
    > On clicking this hyper;link, I would like to open page2.aspx (which is
    > in the same web application) in a new IE window without scrollbars,
    > status bar, tool bar and with specified height and width.
    > Can it be done on "onload" event of the page2.aspx in javascript?


    No, a page cannot modify it's own features for security reasons. You
    must specifiy the features when you open the window. See my reply to
    Eliyahu in this same thread for details.

    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, Jun 7, 2006
    #3
  4. You need to open the page with a javascript call to window.showModalDialog
    function. Look up the MSDN info on this function, you will find how to
    specify the scrollbars and other parameters.

    For the hyperlink, specify url as javascript:showModalDialog(...)

    Eliyahu

    "loga123" <> wrote in message
    news:...
    >I am using asp .net 2.0. I have a hyperlink asp control on my web page
    > page1.aspx.
    > On clicking this hyper;link, I would like to open page2.aspx (which is
    > in the same web application) in a new IE window without scrollbars,
    > status bar, tool bar and with specified height and width.
    > Can it be done on "onload" event of the page2.aspx in javascript?
    >
     
    Eliyahu Goldin, Jun 7, 2006
    #4
  5. Re: how to open a web form in new IE window on clicking hyperlinkwith NO scrollbars, status bar and toolbar?

    Hi,

    Eliyahu Goldin wrote:
    > Laurent,
    >
    > I can only wish you luck in programming in asp.net without javascript. Can I
    > ask if you are aware of any non-javascript asp.net project that would
    > satisfy the customers?
    >
    > The OP's requirements made me think of a dialog window.
    >
    > Eliyahu


    Oh no, believe me, I love JavaScript and use it often. I didn't say you
    shouldn't use JavaScript, I said you shouldn't use "javascript:" as in
    the javascript: pseudo protocol. Sorry I was not being clear.

    The OP's requirement are for a pop-up with specific features. This is
    fulfilled by a modal window, but when ever possible, I try to show the
    browser compatible way to do things in JavaScript. showModelDialog being
    IE only, I wanted to indicate a more compatible way to do things.

    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, Jun 7, 2006
    #5
  6. Laurent,

    I can only wish you luck in programming in asp.net without javascript. Can I
    ask if you are aware of any non-javascript asp.net project that would
    satisfy the customers?

    The OP's requirements made me think of a dialog window.

    Eliyahu


    "Laurent Bugnion" <> wrote in message
    news:44868acf$...
    > Hi,
    >
    > Eliyahu Goldin wrote:
    >> You need to open the page with a javascript call to
    >> window.showModalDialog function. Look up the MSDN info on this function,
    >> you will find how to specify the scrollbars and other parameters.
    >>
    >> For the hyperlink, specify url as javascript:showModalDialog(...)
    >>
    >> Eliyahu

    >
    > Using javascript: is a bad idea and can lead to problems on some
    > platforms. It's much more elegant to use the following construct:
    >
    > <a href="nojs.html" onclick="doSomething();return false;">Click</a>
    >
    > The advantage of this is that the onclick even won't be executed if
    > JavaScript is not present or deactivated, and the link will degrade
    > gracefully and lead the use to a page (nojs.html) explaining why the
    > experience would be better with JavaScript.
    >
    > Besides, showModalDialog is IE only, so using window.open() with a set of
    > chosen features is a better choice. Since the OP doesn't need the window
    > to stay in front (modal), the window.open method is enough.
    >
    > More info here:
    > http://developer.mozilla.org/en/docs/DOM:window.open
    > and
    > http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
    >
    > 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
     
    Eliyahu Goldin, Jun 7, 2006
    #6
  7. loga123

    loga123 Guest

    Thanks for the reply.

    I am using server side (as.net control, not just the anchor tag from
    html) hyperlink control in my application.
    And...."navigateURL" property for this hyperlink is set dynamically in
    my code behind page.
    In such scenario....how can I open a new window w/o scroll bars,
    toolbar, status bar etc...?


    Laurent Bugnion wrote:
    > Hi,
    >
    > Eliyahu Goldin wrote:
    > > You need to open the page with a javascript call to window.showModalDialog
    > > function. Look up the MSDN info on this function, you will find how to
    > > specify the scrollbars and other parameters.
    > >
    > > For the hyperlink, specify url as javascript:showModalDialog(...)
    > >
    > > Eliyahu

    >
    > Using javascript: is a bad idea and can lead to problems on some
    > platforms. It's much more elegant to use the following construct:
    >
    > <a href="nojs.html" onclick="doSomething();return false;">Click</a>
    >
    > The advantage of this is that the onclick even won't be executed if
    > JavaScript is not present or deactivated, and the link will degrade
    > gracefully and lead the use to a page (nojs.html) explaining why the
    > experience would be better with JavaScript.
    >
    > Besides, showModalDialog is IE only, so using window.open() with a set
    > of chosen features is a better choice. Since the OP doesn't need the
    > window to stay in front (modal), the window.open method is enough.
    >
    > More info here:
    > http://developer.mozilla.org/en/docs/DOM:window.open
    > and
    > http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
    >
    > 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
     
    loga123, Jun 7, 2006
    #7
  8. Re: how to open a web form in new IE window on clicking hyperlinkwith NO scrollbars, status bar and toolbar?

    Hi,

    loga123 wrote:
    > Thanks for the reply.
    >
    > I am using server side (as.net control, not just the anchor tag from
    > html) hyperlink control in my application.
    > And...."navigateURL" property for this hyperlink is set dynamically in
    > my code behind page.
    > In such scenario....how can I open a new window w/o scroll bars,
    > toolbar, status bar etc...?


    <asp:HyperLink
    Runat="server"
    ID="lnkOpenWindow"
    Text="Open window" />

    and then on Page_Load

    lnkOpenWindow.NavigateUrl = "nojs.html";
    lnkOpenWindow.Attributes[ "onclick" ]
    = "window.open( 'http://www.galasoft-lb.ch', 'popUpName', "
    + "'width=500,height=300,screenX=50,screenY=100,left=50,top=100');"
    + "return false;";

    This will open a new window without any chromes if JavaScript is
    enabled. screenX and screenY are for Mozilla, left and top are for IE,
    so both must be set.

    If JavaScript is disabled, this navigates to a page named nojs.html
    where you can explain why the user experience is so much better with
    JavaScript ;-)

    Also: this works because the default value for chromes (status bar,
    location bar, etc...) is set to "no". If you want to show only the
    status bar, for example, you must set it explicitly to "yes".

    See
    http://developer.mozilla.org/en/docs/window.open
    for details.

    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, Jun 7, 2006
    #8
  9. loga123

    loga123 Guest

    Hi Laurent ,

    Thanks for your reply.
    I tried with the solution you have. It gives me an error when I click
    on the hyperlink.
    Error says " Invalid argument".
    And arguments for manipulating window features do not seem to work.
    I am using IE.

    Can you help me on this? It's really urgent for me.



    Laurent Bugnion wrote:
    > Hi,
    >
    > loga123 wrote:
    > > Thanks for the reply.
    > >
    > > I am using server side (as.net control, not just the anchor tag from
    > > html) hyperlink control in my application.
    > > And...."navigateURL" property for this hyperlink is set dynamically in
    > > my code behind page.
    > > In such scenario....how can I open a new window w/o scroll bars,
    > > toolbar, status bar etc...?

    >
    > <asp:HyperLink
    > Runat="server"
    > ID="lnkOpenWindow"
    > Text="Open window" />
    >
    > and then on Page_Load
    >
    > lnkOpenWindow.NavigateUrl = "nojs.html";
    > lnkOpenWindow.Attributes[ "onclick" ]
    > = "window.open( 'http://www.galasoft-lb.ch', 'popUpName', "
    > + "'width=500,height=300,screenX=50,screenY=100,left=50,top=100');"
    > + "return false;";
    >
    > This will open a new window without any chromes if JavaScript is
    > enabled. screenX and screenY are for Mozilla, left and top are for IE,
    > so both must be set.
    >
    > If JavaScript is disabled, this navigates to a page named nojs.html
    > where you can explain why the user experience is so much better with
    > JavaScript ;-)
    >
    > Also: this works because the default value for chromes (status bar,
    > location bar, etc...) is set to "no". If you want to show only the
    > status bar, for example, you must set it explicitly to "yes".
    >
    > See
    > http://developer.mozilla.org/en/docs/window.open
    > for details.
    >
    > 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
     
    loga123, Jun 8, 2006
    #9
  10. loga123

    loga123 Guest

    Hi Laurent,

    Thanks a bunch....it works like a charm :)
    I was having ")" after " return false;" and that was causing problem.
    I corrected it now.

    Thanks again


    loga123 wrote:
    > Hi Laurent ,
    >
    > Thanks for your reply.
    > I tried with the solution you have. It gives me an error when I click
    > on the hyperlink.
    > Error says " Invalid argument".
    > And arguments for manipulating window features do not seem to work.
    > I am using IE.
    >
    > Can you help me on this? It's really urgent for me.
    >
    >
    >
    > Laurent Bugnion wrote:
    > > Hi,
    > >
    > > loga123 wrote:
    > > > Thanks for the reply.
    > > >
    > > > I am using server side (as.net control, not just the anchor tag from
    > > > html) hyperlink control in my application.
    > > > And...."navigateURL" property for this hyperlink is set dynamically in
    > > > my code behind page.
    > > > In such scenario....how can I open a new window w/o scroll bars,
    > > > toolbar, status bar etc...?

    > >
    > > <asp:HyperLink
    > > Runat="server"
    > > ID="lnkOpenWindow"
    > > Text="Open window" />
    > >
    > > and then on Page_Load
    > >
    > > lnkOpenWindow.NavigateUrl = "nojs.html";
    > > lnkOpenWindow.Attributes[ "onclick" ]
    > > = "window.open( 'http://www.galasoft-lb.ch', 'popUpName', "
    > > + "'width=500,height=300,screenX=50,screenY=100,left=50,top=100');"
    > > + "return false;";
    > >
    > > This will open a new window without any chromes if JavaScript is
    > > enabled. screenX and screenY are for Mozilla, left and top are for IE,
    > > so both must be set.
    > >
    > > If JavaScript is disabled, this navigates to a page named nojs.html
    > > where you can explain why the user experience is so much better with
    > > JavaScript ;-)
    > >
    > > Also: this works because the default value for chromes (status bar,
    > > location bar, etc...) is set to "no". If you want to show only the
    > > status bar, for example, you must set it explicitly to "yes".
    > >
    > > See
    > > http://developer.mozilla.org/en/docs/window.open
    > > for details.
    > >
    > > 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
     
    loga123, Jun 8, 2006
    #10
    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. Matt
    Replies:
    0
    Views:
    3,550
  2. John Hann
    Replies:
    0
    Views:
    6,082
    John Hann
    Aug 21, 2004
  3. Matt
    Replies:
    9
    Views:
    70,852
  4. Matt
    Replies:
    9
    Views:
    549
    kaeli
    Aug 23, 2004
  5. Ronen Yacov
    Replies:
    1
    Views:
    235
    David Dorward
    Nov 5, 2007
Loading...

Share This Page