I had a problem adding java script in block. Drupal does not parse google ads script in block, if any one can tell me how could i add javascript in my blocks

http://sunilkataria.superihost.com

Comments

media girl’s picture

If you create an input type that allows all code, you can then use that for your js block. You probably will want to limit the permissions of this unrestricted input type to admin user only. Go to administer/input formats, and add a new input format. Then configure it and disable the html filter. I think this should do it for you.
--
mediagirl.org

sunilkataria’s picture

It doesn't seems to be working in my case

Prometheus6’s picture

Use the PHP filter type.

war59312’s picture

Hey,

Yeah I am having a similar problem.

I would like to be able to add simily a windows media player 10 script:


<1script language="JavaScript"><!--
if(navigator.appName=="Microsoft Internet Explorer"){
document.write('<1embed src="file.mp3" autostart="false" loop="1" width=285 height=45></1embed>');}
//-->
</1script>

Of course ignore the 1s in the code. lol Had to do that to post it. ;)

But it does not work. So how can I get it to work. This is the only javascript giving me problems. Others I use work fine.

Know the code is good since it works fine on my own pc.

Thanks,
Will

jweiss’s picture

Will, something I learned this morning was that drupal ignores anything that's commented out and thus doesn't pass it to the browser. Take the

<!-- //-->

out and just leave in

<1script language="JavaScript">
if(navigator.appName=="Microsoft Internet Explorer"){
document.write('<1embed src="1file.mp3" autostart="false" loop="1" width=285 height=45></1embed>');}
</1script>

Yes, i know it's bad form, but it might be worth a shot.

kzeng’s picture

That's the simplest way. I have ad sense block in my website. It works well.

--------------------------
http://www.kzeng.info

jweiss’s picture

Kzeng, I tried your suggestion but it's not working. I also wanted to let you know that I took a look at your site and the google ads weren't showing there either.

jweiss’s picture

I've been playing with this for the last few minutes. It seems if the javascript is in the block, everything works fine. However, if the javascript is referenced such as

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Then it is ignored for some reason. Anyone have any guess as to why this is?

Prometheus6’s picture

Full HTML filter as delivered converts /n to <br />

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"/>
</script/>

will be converted to
<script type="text/javascript"<br />src="http://pagead2.googlesyndication.com/pagead/show_ads.js"/><br/></script/>

Do you know how to configure the input formats? I've changed my Full HTML filter to a no-op.

jweiss’s picture

I've changed my Full HTML input format to not filter anything. I did notice something new, though. When looking at the source code of the finished page, the script reference isn't even showing up. The first part of the google code appears (once I uncommented it) but not the second part that I made reference to above. It makes no sense to me. Can anyone suggest something that I may have over looked or something?