Discuss Base Target using Javascript in the JavaScript Development forum on Dev Shed. Base Target using Javascript JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.
function setTargets() {
var link, l = 0;
while (link = document.links[l++]) {
if (link.href.indexOf('http://www.forum_domainname.com') == -1)
link.target = '_blank';
}
}
</script>
Stick this at the bottom of the file, after all link HTML:
Posts: 1,882
Time spent in forums: 5 Days 21 h 19 m 30 sec
Reputation Power: 17
Ok,
The board is at
http://pub53.ezboard.com/buhelpcanhelpforum
The forum URL's then differ slightly.
e.g.
The Notices and Announcement forum URL is
http://pub53.ezboard.com/fuhelpcanhelpforumfrm23
Then a Topic is
http://pub53.ezboard.com/fuhelpcanhelpforumfrm23.showMessage?topicID=41.topic
What I would like is that all URL's that are not part of those 3 formats to open in a New Window.
So a link posted to http://www.google.com would open a new window.
This is default for several messageboard programs, but not for ezboard
function setTargets() {
var link, l = 0;
while (link = document.links[l++]) {
if (link.href.indexOf('uhelpcanhelpforum') == -1)
link.target = '_blank';
}
}
Posts: 1,882
Time spent in forums: 5 Days 21 h 19 m 30 sec
Reputation Power: 17
Works perfectly.
Although I have found some other problems implementing it, but I'll have a play around with it.
For 2 URL's I could use this?
<script type="text/javascript" language="javascript">
function setTargets() {
var url1 = 'uhelpcanhelpforum'
var url2 = 'another_url'
var link, l = 0;
while (link = document.links[l++]) {
if (link.href.indexOf(url1) == -1 || link.href.indexOf(url2) == -1)
link.target = '_blank';
}
}
var checkURLs = new Array(
'uhelpcanhelpforum' ,
'another_url' ,
'yet_another_url'
);
function setTargets() {
var link, checkit, i, l = 0;
while (link = document.links[l++]) {
i = 0;
while (checkit = checkURLs[i++])
if (link.href.indexOf(checkit) != -1) break;
if (i > checkURLs.length) link.target = '_blank';
}
}