Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Open a new window using Java Script.
WhatsApp
Pradip Pandey
13y
10.2
k
0
0
25
Blog
To open a new window using Java Script, here is the code
window.open('url to open','window name','attribute1,attribute2')
This is the function that allows you to open a new browser window. Note that all the names and attributes are separated with a comma rather than spaces.
Here is what all the stuff inside is:
1.'url to open'
This is the web address of the page you wish to appear in the new window.
2. 'window name'
Name your window whatever you like.
3. 'attribute1,attribute2'
There are so many window attributes that you can adjust.
Window Attributes
Following are the window attributes, that you can use
1. width=300
Width of the new window.
2. height=200
Height of the new window.
3. resizable=yes or no
Use this to control whether or not you want the user to be able to resize the window.
4. scrollbars=yes or no
This lets you decide whether or not to have scrollbars on the window.
5. toolbar=yes or no
Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).
6. location=yes or no
Whether or not you wish to show the location box with the current url (The place to type
http://address
).
7. directories=yes or no
Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).
8. status=yes or no
Whether or not to show the window status bar at the bottom of the window.
9. menubar=yes or no
Whether or not to show the menus at the top of the window (File, Edit, etc...).
10. copyhistory=yes or no
Whether or not to copy the old browser window's history list to the new window.
Here's an example code for opening a new window by using HTML control
<FORM>
<INPUT type="button" value="New Window!" onClick="window.open(
'http://localhost:1296/GridViewWithXMLDataSource/NewPage.aspx','mywindow','width=800,height=500')"> </FORM>
Here's an example code for opening a new window by using ASP.Net control
<asp:Button ID="btnNewWindow" runat="server" onclick="btnNewWindow_Click" onclientclick="window.open('http://localhost:1296/GridViewWithXMLDataSource/NewPage.aspx','mywindow','width=800,height=500',
scrollbars='yes',toolbasr='yes',directories='yes',status='yes',menubar='yes')"
Text="New Window" />
Open a new window using Java Script.
Up Next
var args are new feature of Java 5 and what about C# ?
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
Membership not found