[ad_1]
Plugin Author
room34
(@room34)
The plugin automatically opens links that are on a different domain than your site in a new tab, in keeping with best (or at least “common”) practice in this regard.
There’s not currently a way to override this setting in the plugin, but you could fix it with a bit of your own jQuery that would look something like this:
jQuery('.ics-calendar a').removeAttr('target');
Thanks for the prompt response.
I haven’t used custom jQuery code before. Where would I put this code and how do I make sure it executes after the ICS Calendar jQuery code?
Plugin Author
room34
(@room34)
It would need to go into the script.js (or similar) file in your theme, although you could also just put it in your page adjacent to the ICS Calendar shortcode — you’d need to switch into text mode (in Classic Editor) or add a Classic block and switch it to text mode (in the Block Editor), and put the code in script tags:
<script>jQuery('.ics-calendar a').removeAttr('target');</script>
This is altering HTML generated by ICS Calendar, not jQuery ICS Calendar is doing, so it doesn’t matter when this runs.
Thanks for the advice. I have tried adding the script to my page, but sadly it doesn’t work.
I notice that there is some code in ics-calendar\assets\script.js labelled “Make offsite links open in new tab”. Could that be the cause?
Plugin Author
room34
(@room34)
Ah, yes… that’s right, it’s also doing that (with jQuery) to insert the target attribute in links contained within event descriptions.
That’s happening when jQuery is first initialized, so you may be able to override it by running the code sample I gave you when the page finishes loading. Try this:
<script>jQuery(window).on('load', function() { jQuery('.ics-calendar a').removeAttr('target'); });</script>
I’ll look into adding an option to turn this functionality off directly in the shortcode.
Your revised script suggestion does the job nicely! Thanks so much for your help.
