Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

The title says it all. I want to add a series of advertising javascript code like adsense, facebook likebox javascript code.

How can I add a javascript code as a block and put it on sidebar first. Its not working for me even typing the javascript as FULL HTML but instead drupal displays the source code in my sidebar instead of executing it as javascript.

Can I just COPY PASTE the javascript code in Drupal block, is this possible?

Note: I am using Drupal 8

share|improve this question
    
First do you include any .js file? In chrome Debug function is any error in console. This a bit more strange as Drupal 7/8 will render the js code without problem. When using the Full HTML go to sourch and see is they render as< (html entities) –  Drupalizeme Jun 5 at 9:01
    
@Drupalizeme hi I haven't include it as .js file. I just copy paste it from the block. Is this possible? –  LayoutPH Jun 5 at 9:21
    
Can you include the js code here? –  Drupalizeme Jun 5 at 9:24
    
@Drupalizeme here it is: <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId=611372972302905&version=v2.0"‌​; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like-box" data-href="facebook.com/layoutph"; data-width="200" data-colorscheme="light" data-show-faces="true" data-header="false" data-stream="false" data-show-border="false"></div> –  LayoutPH Jun 5 at 9:29
    
Its a code for Facebook likebox, tomorrow I need to put an adsense code. –  LayoutPH Jun 5 at 9:30
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.