473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with opening a new window

REB
Can someone help me with adding some javascript functionality to a button?

What would the proper syntax for for (please help with the javascript I am
rusty) for doing this:

btnMyButton.Attributes.Add("onclick", **Open a new window with no toolbar or
address bar to address http://mysite.com/viewer.aspx?key= +
mydropdownlist.SelectedValue.ToString()**);

If possible I would want the window to be small and in the center of the
screen.

Thanks,
REB
Nov 18 '05 #1
5 1607
window.open is what you want.
See a clientside/javascript group though, or even a google search will get
you what you are after.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"REB" <ru**@bjorgaard.com> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Can someone help me with adding some javascript functionality to a button?

What would the proper syntax for for (please help with the javascript I am
rusty) for doing this:

btnMyButton.Attributes.Add("onclick", **Open a new window with no toolbar or address bar to address http://mysite.com/viewer.aspx?key= +
mydropdownlist.SelectedValue.ToString()**);

If possible I would want the window to be small and in the center of the
screen.

Thanks,
REB

Nov 18 '05 #2
REB,

If you'd like, I have a "Javascript" project available on my web site:
www.aboutfortunate.com. The project's full source code is downloadable and
everything on my site is free. It includes many commonly used javascripts
including one that easily lets you open new windows on a button click.

At the least it's source code will help you figure out how to write your own
scripts.

Just click the "Code Library" link in the upper right corner of the page and
then click the "Javascript" button in the menu that appears on the left.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"REB" <ru**@bjorgaard.com> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Can someone help me with adding some javascript functionality to a button?

What would the proper syntax for for (please help with the javascript I am
rusty) for doing this:

btnMyButton.Attributes.Add("onclick", **Open a new window with no toolbar or address bar to address http://mysite.com/viewer.aspx?key= +
mydropdownlist.SelectedValue.ToString()**);

If possible I would want the window to be small and in the center of the
screen.

Thanks,
REB

Nov 18 '05 #3
REB
This works but the window after opening loses focus immediately and
disappears behind the calling page.

btnChangeDriverLocation.Attributes.Add ("onClick",
"window.open('ChangeLocation.aspx','', 'width=400, height=300');");

Anyone know how I can keep the window on top of the calling page?
Nov 18 '05 #4
REB
I tried this:
btnChangeDriverLocation.Attributes.Add ("onClick", "var mywindow
=window.open('ChangeLocation.aspx','', 'width=400, height=300');
mywindow.focus();");

No Luck, the pop-up still disappears behind the calling page.

"REB" <ru**@bjorgaard.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
This works but the window after opening loses focus immediately and
disappears behind the calling page.

btnChangeDriverLocation.Attributes.Add ("onClick",
"window.open('ChangeLocation.aspx','', 'width=400, height=300');");

Anyone know how I can keep the window on top of the calling page?

Nov 18 '05 #5
Run code like this in PageLoad.

'Open a centered child window if About button is clicked:

btnAbout.Attributes("OnClick") =
"javascript:lnWidth=500;lnHeight=400;lnTop=(screen .Height-lnHeight)/2;lnLeft
=(screen.Width-lnWidth)/2;window.open('About.aspx','MyAboutBox','toolbar=0 ,m
enubar=0,status=0,scrollbars=1,resizable=1,width=' +lnWidth+',height='+lnHeig
ht+',top='+lnTop+',left='+lnLeft+'');return false;"
btnAbout.Attributes("OnMouseOver") = "javascript:window.status='Open
the About window';"
btnAbout.Attributes("OnMouseOut") = "javascript:window.status='';"

================================================== =====================
Bonus:
'open the print dialog box when the printer image is clicked:
imgPrinter.Attributes("OnClick") = "javascript:window.print();"
imgPrinter.Attributes("OnMouseOver") = "javascript:window.status='Open
the Print Dialog box';"
imgPrinter.Attributes("OnMouseOut") = "javascript:window.status='';"
--
Joe Fallon


"REB" <ru**@bjorgaard.com> wrote in message
news:O%****************@TK2MSFTNGP12.phx.gbl...
I tried this:
btnChangeDriverLocation.Attributes.Add ("onClick", "var mywindow
=window.open('ChangeLocation.aspx','', 'width=400, height=300');
mywindow.focus();");

No Luck, the pop-up still disappears behind the calling page.

"REB" <ru**@bjorgaard.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
This works but the window after opening loses focus immediately and
disappears behind the calling page.

btnChangeDriverLocation.Attributes.Add ("onClick",
"window.open('ChangeLocation.aspx','', 'width=400, height=300');");

Anyone know how I can keep the window on top of the calling page?


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
17
by: Applebrownbetty | last post by:
Hi, I'd like to append/amend the following code from the Dreamweaver extension "Open Picture Window Fever" for the ability to center the PopUp window: By default, it allows the window to be...
1
by: Jarrod Hyder | last post by:
Ok, I wrote my own weblog and I'm working on the web interface for adding/editing my posts. I decided to add a little preview button...when the button is clicked it is suppose to open a pop-up...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
2
by: Keshav Gadia | last post by:
Hi, I am an ASP.net newbie. I am writing a user control that is made up of datagrid with one of the columns opening a new window to display some details on click of the set image. I have...
1
by: pargat.singh | last post by:
Hi Everyone: I am opening new window using HyperLinkField as below. <asp:HyperLinkField HeaderText="Process" Target="_blank" DataTextFormatString="Process me" DataTextField="doc_name" ...
3
by: Lisa | last post by:
Need help with code? Needing Bracelet Size, Anklet Size, Necklace Size (3 Options out of 12 on a Product Page) To look as following Ex: Bracelet Size: Guidelines Guidelines will be a popup...
1
by: chowdary | last post by:
hi, I am using frames in my website,main application links are present on the top of page above mainframe, in main window. These links have target=mainframe, thus opening respective pages in...
4
by: =?Utf-8?B?UGhpbA==?= | last post by:
I am trying to create a multi-document/multi-view app in C#. I have done the MDI, but I don't see how to create multiple views for a document. Can anyone point me in the right direction. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.