1

I am trying to add a Javascript ad code on our Drupal based website through a block and when I do this, the page doesn't display but only ads display. Please see this sample page: http://circuitdigest.com/forums/circuits-and-projects-help/arduino

I tried adding on different blocks and even added the ad code by directly inserting in the codes but no changes. Other Javascript based ad codes from other ad networks are working fine but only had problem with this one.

Could someone let me know what could be the problem? Here is the ad code.

    <script id="mNCC" language="javascript">
    medianet_width = "600";
    medianet_height = "120";
    medianet_crid = "455208315";
    medianet_versionId = "111299";
    (function() {
    var isSSL = 'https:' == document.location.protocol;
    var mnSrc = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/nmedianet.js?cid=8CUWJ3143' + (isSSL ? '&https=1' : '');
    document.write('<scr' + 'ipt type="text/javascript" id="mNSC" src="' + mnSrc + '"></scr' + 'ipt>');})();
    </script>
5
  • 1
    where do you put this code? your block contents? what is your durpal version?
    – Yuseferi
    Feb 15, 2017 at 7:15
  • I have put the code in a block below the content. Drupal version is 7. I have find this code is not working with 'Advanced CSS/JS Aggregation' module. When I am disabling it, the ad code works. So now trying to find a solution how can I get both work together Feb 15, 2017 at 9:04
  • check Advanced CSS/JS Aggregation settings, there are some option for inline css and js. I switched to drupal 8 and don't have drupal 7 on my local machine to tell you exactly which options you should change.
    – Yuseferi
    Feb 15, 2017 at 13:37
  • @zhilevan thank you very much. I disabled "Deferred JavaScript Execution" in sub-module 'AdvAgg Modifier' settings and it worked. Feb 15, 2017 at 17:16
  • you're welcome I post it as a answer for future guys that have the same problem.
    – Yuseferi
    Feb 15, 2017 at 19:32

2 Answers 2

0

Advanced CSS/JS Aggregation Module has several option for inline CSS and JAVASCRIPTS, you can resolve this problem with disabling Deferred JavaScript Execution in sub-module 'AdvAgg Modifier' settings.

0

If you are working on Drupal 8, create a twig like html.html.twig in your themes templates folder and the put your script in there.

<!DOCTYPE html>
<html{{ html_attributes }}>
<head>
    <head-placeholder token="{{ placeholder_token }}">
    <title>{{ head_title|safe_join(' | ') }}</title>
    <script id="mNCC" language="javascript">
    medianet_width = "600";
    medianet_height = "120";
    medianet_crid = "455208315";
    medianet_versionId = "111299";
    (function() {
    var isSSL = 'https:' == document.location.protocol;
    var mnSrc = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/nmedianet.js?cid=8CUWJ3143' + (isSSL ? '&https=1' : '');
    document.write('<scr' + 'ipt type="text/javascript" id="mNSC" src="' + mnSrc + '"></scr' + 'ipt>');})();
    </script>

</head>
<body></body>
</html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.