Search Placementyogi.com
 

Solved : InfoLinks Ad inside pre tag and code tag messing up the page

I recently faced an issue on my website using INFOLINKS AD.

My website has a lot of <code and <pre tags and somehow when the INFOLINKS were getting displayed inside these pre and code tags, they were getting rendered as it is i.e.

 

Here is the actual Picture:

Infolinks Ads inside Pre and Code tags

Consider that this is the code:

<pre >

My pre content appears here.

</pre>

Now, If Infolinks were to correctly render it with an AD:

It should appear like:

<pre >

My pre content appears here.

</pre>

 Where it underlined the "content".

The ISSUE

But what really is happening is, it is getting displayed on the browser like this , disrupting the whole page!!! A Blunder !! 

<pre >

My pre <span id="IL_AD6" class="IL_AD">content</span> appears here.

</pre>


I have raised a ticket for this issue and believe me, The INFOLINKS guys are so much supportive with their prompt reply that they got back in just a few hours and promised to resolve this issue ASAP.

In So, I had to either

1. disable ADS using <!--INFOLINKS_OFF --> to the whole content or 

2. disable ADS only inside these "code" and "pre" tags.

So in the mean time I decided to solve this using Javascript.

Here is my Solution to disable Infolinks only inside pre and code tags

Solution: Disable INFOLINKS ADS in pre and code Tags only 

Add this code to the <head> section of your website:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){

          var newContent = $("code").html(); 

          $("code").replaceWith('<!-- INFOLINKS_OFF --> <code class="myClass">'+newContent+'</code><!-- INFOLINKS_ON -->');

 var newContent = $("pre").html(); 

          $("pre").replaceWith('<!-- INFOLINKS_OFF --> <pre class="myClass">'+newContent+'</pre><!-- INFOLINKS_ON -->');

        });

</script>

Please share this article if you find it useful ! Thanks !



Preview

Thanks for posting your comment! It will be visible soon!
Post Another Comment

6
+
3
=

Name:
Email :
Banner to LogicGuns.com

Hide Page Information