Click to See Complete Forum and Search --> : Opening a link in a new window


Dark Dragon
03-19-2004, 05:12 PM
I want to open a link in a new window..however since I am using XHTML, this poses a new challenge for me.
Here is my link code:

<a href="glyph.htm" class="link" target="new"><img src="images/glyphsmall.jpg" alt="Glyph"/>

Now, as you can see the "target="new" thing doesn't work..so my page which validated won't validate because of the target thing.

Now W3C says this about new window tags
{ target-new: tab ! important }

But where do I put this? In the area of my CSS or in the URL itself?
W3C.org is nice but they are horribly lacking in examples or clarification.

Vladdy
03-19-2004, 05:18 PM
What is wrong with letting user decide where they want this link to be opened :confused:

target-new is part of CSS3 working draft. It will be awhile till it is implemented in browsers (and it has to make it to recommendation first).

Dark Dragon
03-19-2004, 05:21 PM
What is wrong with letting user decide where they what this link to be opened

What is wrong with designing it the way I need it?
I want to simplify my site. Do you actually have an answer for me or are you just going to criticize me?

Vladdy
03-19-2004, 05:27 PM
Originally posted by Dark Dragon
What is wrong with designing it the way I need it?
I want to simplify my site. Do you actually have an answer for me or are you just going to criticize me?

Oh, I did not realize you will keep your site on your hard drive and enjoy your design just the way you like it. In this case why bother specifying DTD, when you can use just one browser???

Simple site is the one that behaves the way everyone expects it to. If I click a link I expect it to come up in the same page. If I want it in a different tab or window, I can do so as well.

If you were not so selt-centered you would recognize an answer when one is given.

Dark Dragon
03-19-2004, 05:36 PM
...If you were not so selt-centered you would recognize an answer when one is given.

Whatever that is supposed to mean.


Anyways..does anyone know what tag is valid for opening up pages in a new window? The page I link to have has one image and nothing else.

Sam
03-19-2004, 06:10 PM
First off, I agree with Vladdy that the user should be able to choose if they want to open a link in a new window or not, so I will not be helping you.

Luckily for you however, there's a new issue of A List Apart (http://www.alistapart.com) out today

Dark Dragon
03-19-2004, 06:24 PM
That is completely within your rights to refuse. :)
I also will not give in to ultimatums.

So..does anyone have a idea of a tag to use?

Sam
03-19-2004, 06:39 PM
Did you look at the link?

steelersfan88
03-19-2004, 07:11 PM
Like the idea of Vladdy to allow the user to choose to open in a new window.

But, i disagree from him henceforth. Vladdy, you might be a helper, not a pleaser, and i can respect that, but please do not continually devalue users who are looking for help.

Users don't need to have a web site that fits all of your standards, he/she can have what he/she wants. Dark Dragon came to receive assistance, not criticism.

I apolizgize to you, Dark Dragon, for having to tolerate this.Originally posted by samij586
so I will not be helping youAnd for this too, for I think it's unethical to reply in contradict the hopes and questions of the original thread starter.

Sam
03-19-2004, 07:35 PM
steelersfan: Note that I did provide a perfectly adequetle solution to his "problem" however, I wanted to make it clear that it wasn't a problem, hence the line you quoted.

Dark Dragon
03-19-2004, 08:04 PM
Thanks for the link Samij...after some consideration I am wondering if it would be just as good to use a CSS based popup or something.


Well..you win then..I may as well have it open in the same window. it appears that the image won't appear in the new window anyways eventhough everything checks out okay. Oh well.

I suppose the new window attribute is useful only if I am using frames and want to break out of them..I think.

Anyways thanks for the link.

Paul Jr
03-19-2004, 08:06 PM
Well, as you have seem to have run into trouble with getting a straight reply, I shall try my hand at giving you one.

To achieve what you want, you'll need a tidbit of JavaScript:

<a href="glyph.htm" class="link" onclick="target='new';"><img src="images/glyphsmall.jpg" alt="Glyph"/></a>

That should do it for ya. ;)

Dark Dragon
03-19-2004, 08:09 PM
"onclick"???

Why didn't I think of that?
Thanks to you too Paul.

By the way, would it work as a way to break out of a frameset?

Paul Jr
03-19-2004, 08:12 PM
Originally posted by Dark Dragon
"onclick"???

Why didn't I think of that?
Thanks to you too Paul.

No pwobwemo. :p

Originally posted by Dark Dragon
By the way, would it work as a way to break out of a frameset?
Y'know... I really haven't a clue. I used frames once in my life, and then I didn't even know what it meant to break out of frames... :D

Dark Dragon
03-19-2004, 08:21 PM
The code worked wonderfully Paul and it validates too :D

Paul Jr
03-19-2004, 08:27 PM
Originally posted by Dark Dragon
The code worked wonderfully Paul and it validates too :D
Woo! :p

Dark Dragon
03-19-2004, 08:32 PM
Heh..I didn't mean to imply that it might not though! ;)
Well..it is a slow process but I want every single page in my site to validate in both XHTML and CSS.

While certain aspects of my site may need revising I want the code to validate. :cool:

Dark Dragon
03-19-2004, 10:15 PM
Hmmm....I thought the onclick event handled things like iframes or javascript popups....but I should test it on a frameset too someday to see if one can break out of them

But I hear that frames are becomming less and less popular, possibly due to incompatibilities with browsers, especially older ones.

Ben Rogers
03-19-2004, 10:59 PM
First of all, my two cents: If this is staying on your hard drive, validation is not an issue, as validation is part of web standards, and therefore if your site isn't on the web, why bother coding to it'd standards?
If you're doing this for practice or for a site, then you should realize pop up windows are annoying, that's the only thing I have against them, and I salut MS IE for offering a right click/ open in same window option. (NO FLAMING, I'M A FIREFOX FAN)

As for actually helping.. you're probably thinking of onlick="window.open('url')"

as for frames, i think this'll work...
<script type="text/javascript">
<!-- // Begin js
var url = "url_of_page";
if(window.location==url) {
} else {
window.location = url;
}
// -->
</script>

That'll redirect to your page if the user has javascript and is on a framed page... if you want it on a url i would say target="_parent" but i don't know if that's valid or not...

Paul Jr
03-19-2004, 11:07 PM
Originally posted by omega
as for frames, i think this'll work...
<script type="text/javascript">
<!-- // Begin js
var url = "url_of_page";
if(window.location==url) {
} else {
window.location = url;
}
// -->
</script>

That'll redirect to your page if the user has javascript and is on a framed page... if you want it on a url i would say target="_parent" but i don't know if that's valid or not...
If you're thinking of a "break out of frames" code, then it'd be more something like this:

<script type="text/javascript">
if(parent.location != self.location) {
window.location = "page.html";
}
</script>

Or some such thing.

The Cheat
03-19-2004, 11:10 PM
wait a second here. What about those people who have javascript disabled. Isn't it like 13% of the internet now?

Whats more important,

using javascript and having your menu not be functional to 13% of the internet

or

using target="_blank" and it will be functional to everybody but your page not being 'valid'

Paul Jr
03-19-2004, 11:13 PM
Originally posted by The Cheat
wait a second here. What about those people who have javascript disabled. Isn't it like 13% of the internet now?

Whats more important,

using javascript and having your menu not be functional to 13% of the internet

or

using target="_blank" and having it will be functional to everybody but your page not being 'valid'
I pick choice C: get rid of the frames and solve both problems. :p :D

Ben Rogers
03-19-2004, 11:14 PM
Well they get the page to open in the same window, lucky them. morals are up to the original poster...

Sam
03-20-2004, 03:59 AM
Originally posted by The Cheat
wait a second here. What about those people who have javascript disabled. Isn't it like 13% of the internet now?

Whats more important,

using javascript and having your menu not be functional to 13% of the internet

or

using target="_blank" and it will be functional to everybody but your page not being 'valid'
actually, its only 5% as of last month (http://www.thecounter.com/stats/2004/February/javas.php)

Dark Dragon
03-20-2004, 11:56 AM
I used Paul Jrs code and it worked really nice too.
I agree .....I dislike popup windows too..I thought it might have been a good idea to use it if I only have one image to display rather than opening it up in the same window..it kinda seemed like a waste.

That is why I asked the original question...if anyone had bothered asking me why instead of jumping on me I would have explained it.

But...that is all water under the bridge.

Thanks for the code help...I find them very helpful..unfortunately, if someone has an ad blocker..won't it block any javascript that attempts to open a new window of any sort?

Ben Rogers
03-20-2004, 12:06 PM
Heh.. heh... I didn't jump on you for the pop up *shifty eyes*

I don't think target="_blank" will be blocked or a simple window.open('filename'), as long as it's onclick. I think it will be blocked it if it's onload...

Paul Jr
03-20-2004, 12:09 PM
Originally posted by Dark Dragon
I used Paul Jrs code and it worked really nice too.
I agree .....I dislike popup windows too..I thought it might have been a good idea to use it if I only have one image to display rather than opening it up in the same window..it kinda seemed like a waste.
Most of the time pop-ups are quite annoying, but sometimes they can be tasteful. ;)


Originally posted by artemisia
unfortunately, if someone has an ad blocker..won't it block any javascript that attempts to open a new window of any sort?
Generally, I believe most pop-up blockers will only block unrequested pop-ups. Like the pop-up blocker on Firebird will still allow a window to be opened if I click on a link to open it.

Dark Dragon
03-20-2004, 12:10 PM
You are right Omega..you didn't..I did not mean to imply that.

Dark Dragon
03-20-2004, 12:13 PM
Generally, I believe most pop-up blockers will only block unrequested pop-ups.

I don't think that is entirely accurate though.

Even functional popups like the ones used on some Photoshop tutorials sites are blocked by AdSubtract.

But I just temporarily disable it so I can use it.

Ben Rogers
03-20-2004, 12:14 PM
I was being sarcastic, when I said 'heh heh i didn't jump on you for the pop up'. I was hasty to trash u for it. I automatically assume people have the worst intentions ;)

Yeah, it works the same way for me, Paul.

Paul Jr
03-20-2004, 12:24 PM
Originally posted by Dark Dragon
I don't think that is entirely accurate though.

Even functional popups like the ones used on some Photoshop tutorials sites are blocked by AdSubtract.

But I just temporarily disable it so I can use it.
Eh, well I wouldn't really know. I've never used any Pop-up blocker software/tool, except for the built-in one for Firebird -- which happens to be excellent. :p

Ben Rogers
03-20-2004, 02:22 PM
I have used some pop-up blockers myself, and they've all performed the same.

For the record, I've used Firefox's blocker, Mozilla's blocker, StopZilla trial ware, and Google toolbar for IE.