How do I open a new browser window programmatically?

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

How do I open and change properties of (such as size, position, scroll
position, visibility of toolbars, etc.) a browser window? Thanks.
 
R

Roy

Use javascript.

<SCRIPT LANGUAGE="javascript">window.open('somepage.html')</SCRIPT>

is the basic syntax.
 
N

Nathan Sokalski

I know how to open a new window using Javascript, and id I have to manually
write the Javascript that's OK, but how do I call the Javascript from a
method in ASP.NET code? For example, I want the new window to open when a
specific event occurs on my page. (I use VB.NET as my language when making
my ASP.NET pages) How do I do this? Thanks.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Roy said:
Use javascript.

<SCRIPT LANGUAGE="javascript">window.open('somepage.html')</SCRIPT>

is the basic syntax.
 
N

Nathan Sokalski

I understand everything about the Javascript window.open method and how
popup blockers may cause problems when using it. This is why I have been
looking for a way to open a new browser window using ASP.NET without
manually writing the Javascript. But if I do use Javascript, how do I tell
ASP.NET code written in VB.NET to call it? The specific purpose I plan to
use this for is when to open a printable version of a page when the user
clicks a button. I would rather use an ImageButton control than nest and
Image control inside of a HyperLink control with a Target property of
_blank. This way I can use less controls and I would also like to use the
CommandArgument property of the ImageButton control. Thanks.
 
R

Roy

I noticed from your other message that you're trying to use ASP.NET to
open a new window. Long story short: you can't (or at least not in any
comparably simple way that javascript allows for). Ya gotta use
javascript.

I did a job similar to what you're describing not too long ago. I
placed the javascript syntax within a global VB variable in the
page_load area. You may already know that VB.NET = server-side and
javascript = client-side. By placing the javascript within a VB
variable you get around this and sorta merge the two, but I digress...
In the button click event (I was using a <asp:buttton> in my job) I did
a response.write() *using that variable* and thusly passed back the
javascript back to the client for processing.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top