Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Open external links in a new window? (target="blank"?)
blizeH
✭✭
Hey guys,
A lot of users on the forum I run have requested that windows open in a new window (IE users eh!) when you click on them.
I thought I could easily amend the anonymize plugin to do this:
Cheers
A lot of users on the forum I run have requested that windows open in a new window (IE users eh!) when you click on them.
I thought I could easily amend the anonymize plugin to do this:
$("a:external").attr("href", function () {... but of course this just changes the actual address, not the a tag! Any suggestions please? I've had a look through the core PHP files and couldn't really see anything relating to it.
// ... prepending the prefix to the original value
return prefix + $(this).attr("href") + ' target="blank"';
});
Cheers
0
Comments
$("a:external").attr("target", 'blank');
Hi Mark,
Thanks for the tip. I am new to Vanilla. Just set it up within iframe of my site and the links are not opened in a new window. Where do I add your line of code to maek this happen? Thanks.
this is a jquery line and will go in any javascript files or in your page - if you are familiar with jquery
There was an error rendering this rich post.
Thanks sahotataran. I haven't used JQuery, but other JS libararies. I see Vanilla deployed with jquery in the js folder. Is index.php a good place to put this code? I don't see any in that file. Should I create a conf/bootstrap.after.php to add this custom code?
no. you use your theme for adding additional code.
open /themes/yourtheme/views/default.master.php or default.master.tpl - you can add the above code in head using
There was an error rendering this rich post.
Great. Thanks! You pointed me to the right direction. Looks like there are some reading for me to do regarding to the customization of Vanilla.
reminds me that whenever i add jquery to the default.master.tpl it bonks out
as in jquery.js ? its already loaded though @redtwentyfour
There was an error rendering this rich post.
nono, i mean whenever i add any jquery code
Always add it to the footer
If you try and render jquery before jquery.js loads it will fail
There was an error rendering this rich post.
Hmm, tried both to add it in either
<div id="Foot">
or<head>
but not working. I don't have customized theme. There is one "EmbedFriendly" in the folder, so added in EmbedFriendly/views/default.master.tpl. I tried to just put alert('hi') but it did nothing. Doesn't seem like this file is loaded?Probably issue with including file. The file is not at URL at which it was included probably
There was an error rendering this rich post.
You want to put javascript between
{literal}..{/literal}
tags if you are using smarty. Otherwise it will interpret your javascript curly braces as smarty tags.