English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want some links in my page to open in a new window. So, i'm using "target=_blank" with 'a' element. While checking the code with dreamweaver, its giving the result- "target attribute is not a valid xhtml.."
How can I code it in CSS. I don't know the code. Please help

2007-02-21 22:32:26 · 3 answers · asked by virus_photo 3 in Computers & Internet Programming & Design

3 answers

Copy this code and save as external.js (a javascript program) in an external file:

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;

Then load on every page in the , like this:


Then when you want to have something open in a new window, write it like this:

YourLink

That should do it!

2007-02-22 00:43:31 · answer #1 · answered by DianeD 4 · 0 0

You could use this:

onclick="window.open(this.href , '_blank'); return false;"
href="http://some_site.com">Some Site


(Sorry for the splitted code but the entry was getting cutted by the terrible 3 dots ... )

XHTML will not validate the target="_blank" so you have to do some scripting in javascript.

Hope this helps.

2007-02-21 23:41:33 · answer #2 · answered by f0vela 2 · 0 0

Well... you should copy paste the lines of code with the problem for better answers...

I'll just guess you're writing "target=_blank" ...
The code should go like this-
Click me

2007-02-21 23:40:37 · answer #3 · answered by Amlan 2 · 0 0

fedest.com, questions and answers