View Full Version : Resolved offsite links Resolved
FredPitt
02-12-2009, 11:12 AM
http://www.dynamicdrive.com/dynamicindex8/newwindow2.htm
Is it possible to change this script in a manner that it opens all links in a new window? So even if they are of my own domain.
Now I am using the "target="_blank" syntax, but W3C does not like "target"
When using this script, W3C does not complain.
Snookerman
02-12-2009, 12:10 PM
Just make sure your site is not mentioned here:
//1)Enter domains to be EXCLUDED from opening in new window:
excludedomains: ["dynamicdrive.com", "google.com"],
Good luck!
codeexploiter
02-12-2009, 12:43 PM
I have changed the assigntarget function and furnished below. Comment the default one and insert this one.
assigntarget: function() {
var rexcludedomains = new RegExp(this.excludedomains.join("|"), "i") var all_links = document.getElementsByTagName("a") if (this.mode == "auto" || (this.mode == "manual" && this.togglebox.checked)) {
for (var i = 0; i <= (all_links.length - 1); i++) {
if (all_links[i].hostname.search(rexcludedomains) == -1 && all_links[i].href.indexOf("http:") != -1)
if (ddwindowlinks.linktarget === '_blank') {
all_links[i].removeAttribute('target');
all_links[i].onclick = function() {
window.open(this.href, "");
return false;
};
}
}
} else {
for (var i = 0; i <= (all_links.length - 1); i++) all_links[i].target = ""
}
if (this.mode == "manual" && this.persist) this.setCookie("dlinktarget", (this.togglebox.checked) ? "yes": "no", 30) //remember user setting for 30 days (set to -1 then reload page to erase cookie)
}
At the moment I haven't used any of the parameters that can be used while opening a new window. You can use them based on your requirement.
Hope this helps.
FredPitt
02-12-2009, 12:44 PM
You are right, but I did not mention my domain there.
But your answer made me understand what was wrong:
The link (to a page of my domain) referred directly to it`s place on the host.
In that case it opens in the same window.
Now I changed it to it`s complete internet address and it opens in a new window. Problem solved, thanks!
Snookerman
02-12-2009, 12:48 PM
You're welcome, glad to help!
You can go to your first post in this thread, click http://www.dynamicdrive.com/forums/images/buttons/edit.gif then click Go Advanced and add the Resolved prefix to the thread title.
This will let other users know the problem has been solved.
Good luck with your site!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.