pre - JavaScript
Testing if Search engines will see a page as indexable if a
is removed by
an external JavaScript file, and if it executes the JavaScript on the page when rendering.<meta name="robots" content="noindex">
This page calls a script which has this function:
function doTheThing() {
// remove the meta tag with name "robots"
var meta = document.querySelector('meta[name="robots"]');
if (meta) {
meta.parentNode.removeChild(meta);
}
// change the text of the paragraph with id "changeThis"
var paragraph = document.getElementById('changeThis');
paragraph.innerHTML = 'post - JavaScript';
fetch('/cont_api/api.php', {
method: 'POST',
body: JSON.stringify({
'action': 'getExternal',
}),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
return response.json();
}).then(function (data) {
var container = document.getElementById('fetchContainer');
container.innerText = data.message;
}).catch(function (error) {
console.error('Error:', error);
});
}
Just before the </body>