pre - JavaScript
Testing if Search engines will see a page as indexable if a
is removed by
JavaScript, and if it executes the JavaScript on the page when rendering.<meta name="robots" content="noindex">
This page has:
document.addEventListener('DOMContentLoaded', function () {
// 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': 'get',
}),
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>