I am new to CSS.
How can I create pop-up window? And also a link on the window that when clicked on will shut down the window?
Please help.
Thanks.
| SitePoint Sponsor |
I am new to CSS.
How can I create pop-up window? And also a link on the window that when clicked on will shut down the window?
Please help.
Thanks.





<p><a href="javascript:window.close()">Close</a></p>
will close a page, but it's even better to add this line as well
<body onBlur="javascript:window.close()">
which will close it as soon as the user goes elsewhere, and no-one likes having lots of little orphan windows still open.
Dr John
www.kidneydialysis.org.uk

"Never pop up any windows, ever" is a pretty good rule of web design.
Learn all about diamonds,
Check out some period-drama movies and TV series,
Or get festive with The Wonder of Christmas.

You can only close a window if you opened the window and the same page as you first loaded into the window is still displayed in it.
You can't guarantee that any code will open a new window because where new pages open is completely under the control of your visitors - they may prefer to have it open in a new tab or even the same tab instead and there is no way you can prevent that or tell where they have opened it.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">

You can't use only CSS to create a pop-up window, you need Javascript.
to create a pop-up window you will use a link like this
In this way, the link will always work because the href attribute does have an address.Code:<a href="http://google.com/" onclick="window.open(this.href, 'popupwindow', width=400,height=300,scrollbars,resizable'); return false;"> Text of the link here. </a>
Remember that pop-ups are unreliable because they have been abused badly. Most browsers come with pop-up blockers and some users have javascript turn off, so don't place any critical information there because your users may not see it. If anything, something that can help them but they don't need to enjoy the site.
Before asking, do a search... if you don't find the answer, then ask
The purpose of this forum is to help others in the community, that's why it's called Sitepoint and not Linkpoint.
SP Guidelines - No fluff.
Thinking Web: Voices of the Community - The Community Book
What I want exactly is to put links of other websites on my web page but when clicked I want them to open on a new window.
Thank you very much.
I am designing a portfolio web page. I would like to put a link where by when clicked it opens the main image in a new window in a particular width and height.
Please help....
Thank you.

Before asking, do a search... if you don't find the answer, then ask
The purpose of this forum is to help others in the community, that's why it's called Sitepoint and not Linkpoint.
SP Guidelines - No fluff.
Thinking Web: Voices of the Community - The Community Book

You are supposed to leave it to your visitors to decide where they want pages to open.
They can choose between same tab, new tab, or new window. You can only suggest new window for if they don't override it with their own choice.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
But can I control the size of the new opened window in terms of width and height?


Ah, "popup" windows with CSS. I take it you're looking for something like this? http://battletech.hopto.org/for_others/ag/template.html
The directory is open, if you want to view the source code.
http://battletech.hopto.org/for_others/ag/
(Note: This is not my site; it belongs to a friend of mine.)
Save the Internet - Use Opera | May my mother rest in peace: 1943-2009
Dan Schulz - Design Team Advisor | Follow me on Twitter
SitePoint References: HTML CSS JavaScript | Become A Guru
WordPress SEO Checklist | What WordPress Plugins Do You Use?
Web Standards Curriculum | Image Free Equal Height Columns
Bookmarks