PDA

View Full Version : Javascript to check if page content contains an phrasse



Fli
11-12-2014, 03:12 PM
Hello,

i want to insert Adsense only on the pages where certain phrasse like "Casino" is not within the text on the webpage.
please can anyone share tutorial on how to achieve this?

I found an Javascripts like:


if (
(
document.documentElement.textContent || document.documentElement.innerText
).indexOf('Done successfuly') > -1
) {
// Do something...
}

and


<!-- Place this in the <head> section to avoid it erroneously including this in what to search -->
<script type='text/javascript'>
window.onload = function(){
//If the body element of the page contains 'with Gene 101' then trigger an alert
if(document.body.innerHTML.toString().indexOf('wit h Gene 1001') > -1){
alert("It contains 'with Gene 1001'");
}};
</script>

I think such script should go into footer so it dont delay webpage, but im unsure how to use this script to list another javascript code on the webpage. (adsense code using "<script" tags..)