/    Sign up×
Community /Pin to ProfileBookmark

Opening a link in a new window

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:

[code=php]<a href=”glyph.htm” class=”link” target=”new”><img src=”images/glyphsmall.jpg” alt=”Glyph”/>[/code]

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
[COLOR=darkred]{ target-new: tab ! important }[/COLOR]

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.

to post a comment
HTML

31 Comments(s)

Copy linkTweet thisAlerts:
@VladdyMar 19.2004 — What is wrong with letting user decide where [b]they[/b] want this link to be opened ?

target-new is part of CSS3 [b]working draft[/b]. It will be awhile till it is implemented in browsers (and it has to make it to recommendation first).
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 19.2004 — What is wrong with letting user decide where they what this link to be opened [/QUOTE]

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?
Copy linkTweet thisAlerts:
@VladdyMar 19.2004 — [i]Originally posted by Dark Dragon [/i]

[B]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? [/B]
[/QUOTE]


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.
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 19.2004 — ...If you were not so selt-centered you would recognize an answer when one is given.[/QUOTE]

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.
Copy linkTweet thisAlerts:
@SamMar 19.2004 — 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 [URL=http://www.alistapart.com]A List Apart[/URL] out today
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 19.2004 — 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?
Copy linkTweet thisAlerts:
@SamMar 19.2004 — Did you look at the link?
Copy linkTweet thisAlerts:
@steelersfan88Mar 20.2004 — 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.[i]Originally posted by samij586[/i]

[b]so I will not be helping you[/b][/quote]
And for this too, for I think it's unethical to reply in contradict the hopes and questions of the original thread starter.
Copy linkTweet thisAlerts:
@SamMar 20.2004 — 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.
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — 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.
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — 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:
[size=1]
&lt;a href="glyph.htm" class="link" [color=red]onclick="target='new';"[/color]&gt;&lt;img src="images/glyphsmall.jpg" alt="Glyph"/&gt;&lt;/a&gt;
[/size]

That should do it for ya. ?
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — "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?
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — [i]Originally posted by Dark Dragon [/i]

[B]"onclick"???



Why didn't I think of that?

Thanks to you too Paul.

[/b]
[/quote]

No pwobwemo. :p

[i]Originally posted by Dark Dragon [/i]

[B]By the way, would it work as a way to break out of a frameset? [/B][/QUOTE]

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... ?
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — The code worked wonderfully Paul and it validates too ?
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — [i]Originally posted by Dark Dragon [/i]

[B]The code worked wonderfully Paul and it validates too ? [/B][/QUOTE]

Woo! :p
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — 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. ?
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — 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.
Copy linkTweet thisAlerts:
@Ben_RogersMar 20.2004 — 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...
&lt;script type="text/javascript"&gt;
&lt;!-- // Begin js
var url = "url_of_page";
if(window.location==url) {
} else {
window.location = url;
}
// --&gt;
&lt;/script&gt;


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...
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — [i]Originally posted by omega [/i]

[B]as for frames, i think this'll work...

&lt;script type="text/javascript"&gt;
&lt;!-- // Begin js
var url = "url_of_page";
if(window.location==url) {
} else {
window.location = url;
}
// --&gt;
&lt;/script&gt;


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... [/B][/QUOTE]

If you're thinking of a "break out of frames" code, then it'd be more something like this:
<i>
</i>&lt;script type="text/javascript"&gt;
if(parent.location != self.location) {
window.location = "page.html";
}
&lt;/script&gt;

Or some such thing.
Copy linkTweet thisAlerts:
@The_CheatMar 20.2004 — 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'
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — [i]Originally posted by The Cheat [/i]

[B]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' [/B]
[/QUOTE]

I pick choice C: get rid of the frames and solve both problems. :p ?
Copy linkTweet thisAlerts:
@Ben_RogersMar 20.2004 — Well they get the page to open in the same window, lucky them. morals are up to the original poster...
Copy linkTweet thisAlerts:
@SamMar 20.2004 — [i]Originally posted by The Cheat [/i]

[B]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' [/B]
[/QUOTE]

actually, its only 5% as of last month (http://www.thecounter.com/stats/2004/February/javas.php)
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — 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?
Copy linkTweet thisAlerts:
@Ben_RogersMar 20.2004 — 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...
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — [i]Originally posted by Dark Dragon [/i]

[B]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.[/B]
[/QUOTE]

Most of the time pop-ups are quite annoying, but sometimes they can be tasteful. ?


[i]Originally posted by artemisia [/i]

[B]unfortunately, if someone has an ad blocker..won't it block any javascript that attempts to open a new window of any sort? [/B][/QUOTE]

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.
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — You are right Omega..you didn't..I did not mean to imply that.
Copy linkTweet thisAlerts:
@Dark_DragonauthorMar 20.2004 — Generally, I believe most pop-up blockers will only block unrequested pop-ups. [/QUOTE]

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.
Copy linkTweet thisAlerts:
@Ben_RogersMar 20.2004 — 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.
Copy linkTweet thisAlerts:
@Paul_JrMar 20.2004 — [i]Originally posted by Dark Dragon [/i]

[B]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. [/B]
[/QUOTE]

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
Copy linkTweet thisAlerts:
@Ben_RogersMar 20.2004 — 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.
×

Success!

Help @Dark_Dragon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...