I am working on a sharepoint online classic team site. and i have added a Calendar list named Events. but inside the calendar view, when i click on an event, the event's display form will open inside the current page, while i am trying to force the event's display form to open in a new tab.
Here is my calendar view:-
I tried to edit the calendar view page >> I add a script editor web part >> then i added the following JavaScript code inside the script editor, the JavaScript will get all the links which have the listname/display form name
inside their href attributes, and add .attr('target', '_blank');
to the link , as follow:-
<script>
function MyFunction() {
$('a[href*="Events/Disp"]').attr('target', '_blank');
}
_spBodyOnLoadFunctionNames.push("MyFunction");
$(document).on('click','a',function(e){
$('a[href*="Events/Disp"]').attr('target', '_blank');
});
</script>
but this script did not work, where still my events will open inside the current page, and not on a new tab.
Here is a sample of the markup for a single calendar event, which i am trying to modify:-
> <a onclick="EditLink2(this,'WPQ2');return false;"
> href="/Events/DispForm.aspx?ID=1">General Meeting</a>
can anyone advice on this please? Thanks