I have tried a few solutions for including VBA but now I move to JavaScript. I want to insert hyperlinks to an array of specific keywords. Which I have been able to do, but the array of keywords specified are capital sensitive in the JavaScript code. Is there any way to make the following code capital insensitive when inserting hyperlinks for specific keywords. Any help will be greatly appreciated.
//your array word list
var words = [
{
word: "Cape York tours from Cooktown",
link: "https://www.farnorthescapes.com.au/daintree-tours-trips/cape-york-tours-from-cooktown",
},
{
word: "Port Douglas to Cooktown tours",
link: "https://www.farnorthescapes.com.au/daintree-tours-trips/cooktown-tours-from-port-douglas",
},
];
$(function () {
//iterate the array
$.each(words, function () {
var searchWord = this.word;
var link = this.link;
$('body:contains("' + searchWord + '")').each(function () {
var newHtml = $(this)
.html()
.replace(
searchWord,
'<a class="wikilink" title="here is a link to Wikipedia" href="' +
link +
'">' +
searchWord +
"</a>"
);
$(this).html(newHtml);
});
});
});
// tell the embed parent frame the height of the content
if (window.parent && window.parent.parent) {
window.parent.parent.postMessage(
[
"resultsFrame",
{
height: document.body.getBoundingClientRect().height,
slug: "ju0L2m4x",
},
],
"*"
);
}
// always overwrite window.name, in case users try to set it manually
window.name = "result";
I tried a few options of capital insensitive and can't get it to work.