Click to See Complete Forum and Search --> : How Do I Open a Pop Up Window
ScottyBoy
07-22-2009, 07:32 PM
How do I open link in a pop up window?
So far I have something like this...
<a href="LINK"><button>Push Me</button></a>
What can I put in the code to make the link open in a new window?
Oh, and is there a way to specify the new window size?
ryanbutler
07-23-2009, 08:13 AM
Here ya go:
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
If you happen to have Dreamweaver, look up Smart Link on Google.
ScottyBoy
07-23-2009, 10:22 AM
Thank you. :)
kiwibrit
07-23-2009, 11:14 AM
If you happen to have Dreamweaver, look up Smart Link on Google.
Nice one.
hidjan
08-01-2009, 05:36 AM
it can be way easyier without the javascript
trie this:
<a href="http://urwebpage.com" target="blank"><button>Push Me</button></a>
greetz
kiwibrit
08-01-2009, 08:27 AM
hidjan, I hope you meant
target="_blank"
All very well, but will validate only in a transitional doctype, and, depending on how the user's browser is configured, may open up in a separate tab rather than a new window. The OP specifically asked for a popup; I think javascript is the best option, but there should, ideally, be an alternative for those browsing without javascript enabled.
Charles
08-01-2009, 08:33 AM
Actually, the proper way to open a pop up is always with JavaScript. Users turn off JavaScript because they don't want those cursed pop-ups.
You can use "blank" or "_blank" as the value of the "target" attribute in a link but the two mean different things. "blank" will look for a window or frame with that name and then load the page there. If it doesn't exist it will open a new window with that name. The second time the page will load in that same window. "_blank" will always open a new window so you can end up with lots and lots of windows open.
And that link the Mr. Butler provided, stay away. There is a lot of very bad information there.
ryanbutler
08-01-2009, 03:44 PM
And that link the Mr. Butler provided, stay away. There is a lot of very bad information there.
You know its posters like you that irritate me. You say that, but you provide no additional information about what you're referring to. It's like a kid asking a teacher in kindergarten what they did wrong and the teacher saying "you just did something bad." The only possible thing I can think of that would be bad with the link I provided is if you didn't provide a URL, then it would return an empty window. In that case, specify a return false on the anchor tag when you call that function.
Charles
08-01-2009, 05:45 PM
That page suggests that the method takes three parameters, the first two required and the third optional, all are optional. And there are four or them. The HTML documents shown omit required elements. The SCRIPT element as shown omits the required "type" attribute. But it includes the depricated "language" attribute. The last example shows the "javascript:" pseudo-scheme prepended in the value of the onunload handlerI expect that I've only scratched the surface but it pains me to look upon such shoddy work.
ryanbutler
08-02-2009, 02:20 PM
You're referring to semantics, not the quality of what's demonstrated. When I write .NET articles, just because I don't put all elements in a constructor, when two might be optional, doesn't mean the code is crap, it means they are multiple ways of doing it.
You're also referring to accessible JavaScript when referring to the on load calls because it's included in the body tag, which is sometimes referred to as inaccessible JavaScript because it's not separated into a separate JS file. That could be debated any day of the week. Thought that debate died a few years back.
You do realize that's a site for JavaScript examples, not advocating an HTML example. If you're really going down that slippery slope of criticizing examples that are concentrating on HTML, then half the articles on the net are just as crappy, when people write about .NET but don't into account the often crappy HTML it outputs.
Charles
08-02-2009, 04:12 PM
Semantics is the study of meaning. I don't have a problem with taking issue with what that page means.
There is no way around it, open (URL, windowName[, windowFeatures]) is incorrect for two separate and egregious reasons. And as the standard is to include what is returned when giving the formal definition I would add that it is incorrect for a third, trivial reason as well.
My problem with the last example has nothing to do with providing the handler as a value of the "onunload" attribute--and avoiding that technique has nothing to do with accessibility but everything to do with maintenance--but with the fact that the example given is incorrect. There should be no "javascript:".
That the examples show incorrect HTML may be acceptable to your mind but they do spread misinformation, something that is to be avoided. But they do seem to be consistent with the quality of the JavaScript information.