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

  • Thread starter Thread starter loga123
  • Start date Start date
L

loga123

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?
 
Hi,

Eliyahu said:
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
 
Hi,
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
 
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
 
Hi,

Eliyahu said:
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,

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
 
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...?
 
Hi,
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
 
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 said:
Hi,
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
 
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

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 said:
Hi,
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
 
Back
Top