which links do you want to be opened in a new windows?
If it is the links in the comments, the Extended Text Formatter already do that I think. function AutoLink($String) {
$String = str_replace(array(""","&"),array('"','&'),$String);
$String = preg_replace(
"/
(?<!<a href=\")
(?<!\")(?<!\">)
((https?|ftp):\/\/)
([\@a-z0-9\x21\x23-\x27\x2a-\x2e\x3a\x3b\/;\x3f-\x7a\x7e\x3d]+)
/msxi",
"<a href=\"$0\" target=\"_blank\" rel=\"nofollow\">$0</a>",
$String);
return $String;
}
I have Extended Text Formatter 1.0 activated, but it replaces only the web-adresses through a link... it doesn't open it in a new window. I use also the bbcode and bbcode-buttons extenions, is there a possibility to make it there?
i prefer to have control over how I open my links (middle mouse click opens a link in a new tab in Firefox, thank you), and hate when sites/forums force a link to open in a new window.
Our Vanilla installation is based in an iframe (I know, I know), and we have to have user posted links open in a new window. How can we do this and where do we apply the code? The new window extension does not work for us whatsoever for some reason.
Are these links to other sites, or links to other parts of your own site? The extension only opens external links in a new window. If you want it to open all user posted links in new windows, this might work:
Open functions.js and look for the following line: if (fileLink.href.match(/^(http|https)/) && (fileLink.href.indexOf(location.hostname) == -1)) {
and replace it with this: if (fileLink.href.match(/^(http|https)/)) {
Comments
how to make this javascript thing in vanilla?
I think this option should be "user editable" in vanilla settings to let the admin decide how to make it on his forum
It contains two possible Javascript solutions. here and here.
If you want it user editable, an extension would be the way to go!
If it is the links in the comments, the Extended Text Formatter already do that I think.
function AutoLink($String) { $String = str_replace(array(""","&"),array('"','&'),$String); $String = preg_replace( "/ (?<!<a href=\") (?<!\")(?<!\">) ((https?|ftp):\/\/) ([\@a-z0-9\x21\x23-\x27\x2a-\x2e\x3a\x3b\/;\x3f-\x7a\x7e\x3d]+) /msxi", "<a href=\"$0\" target=\"_blank\" rel=\"nofollow\">$0</a>", $String); return $String; }
> Window Links
By the way, that extension lets users choose whether or not they want links to open in a window.
Open functions.js and look for the following line:
if (fileLink.href.match(/^(http|https)/) && (fileLink.href.indexOf(location.hostname) == -1)) {
and replace it with this:
if (fileLink.href.match(/^(http|https)/)) {
Hope that helps!
I have one question, is there any way to enable it by default instead of having the users individually enabling it?