+ Post New Thread
Results 1 to 3 of 3

Thread: Javascript to check if page content contains an phrasse

  1. #1
    Fli
    Fli is offline
    Administrator Fli's Avatar
    Join Date
    Mar 2013
    Posts
    2,474

    Javascript to check if page content contains an phrasse



    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:

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

    Code:
    <!-- 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('with 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..)

  2. #2
    Junior Member Formidable's Avatar
    Join Date
    Dec 2019
    Posts
    4
    Thanks/ very interesting

  3. #3
    Junior Member Formidable's Avatar
    Join Date
    Dec 2019
    Posts
    4
    Did you by yourself write this code?

+ Post New Thread

Similar Threads

  1. How To Check Web Content Tool..?
    By pihu147741 in forum SEO - Search Engine Optimisation
    Replies: 1
    Last Post: 12-21-2018, 11:33 AM
  2. How to check the Page rank of a website ?
    By mahisharma3200 in forum SEO - Search Engine Optimisation
    Replies: 6
    Last Post: 04-08-2017, 09:03 AM
  3. How to check page speed..?
    By swatijain2233 in forum General Webmaster Discussion
    Replies: 2
    Last Post: 10-07-2016, 07:54 PM
  4. Javascript - click to hide/show text/content
    By Fli in forum Javascript Forum
    Replies: 0
    Last Post: 03-11-2015, 03:59 PM
  5. Replies: 0
    Last Post: 06-26-2013, 01:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam