@tdelillo ,
I have revised the function to include the ability to have the new link open in a new tab. Here is the new function:
function addMenuItem (linkText, linkhref, icon, target) {
var iconHtml = '',
itemHtml,
linkId = linkText.split(' ').join('_'),
newTab = '';
if (typeof target !== 'undefined') {
newTab = 'target="' + target + '"';
}
if (icon !== '') {
iconHtml = '<i class="' + icon + '"></i> ';
}
itemHtml = '<li class="ic-app-header__menu-list-item ">' +
' <a id="global_nav_' + linkId + '" href="' + linkhref + '" class="ic-app-header__menu-list-link" ' + newTab + '>' +
' <div class="menu-item__text">' + iconHtml + linkText + '</div>' +
' </a>' +
'</li>';
$('#menu').append(itemHtml);
}
To create a link that opens in the current window, use the following (same as original):
addMenuItem('Library', 'http://mylibrarylink.edu', 'icon-educators');
To create a link that opens in a new window, add an additional parameter to the end:
addMenuItem('Library', 'http://mylibrarylink.edu', 'icon-educators', '_blank');
Just in case this is not common knowledge to those reading this response, adding target="_blank" to an anchor tag will cause that link to open in a new window.
I fixed the part of the code that pasting into this reply usually breaks and I didn't see any new breaks, but let me know if there are any issues.