Hello everyone,
I want to create a new block with this code inside.

<script type="text/javascript" language="JavaScript" src="http://hypem.com/playlist/time/today/js/1/hype.js"></script>

It doesn't work.

I tried to found an answer in this forum but nothing works.
Can anyone help me?

Comments

nevets’s picture

If you use the PHP input format the javascript will not be filtered out (both HTML filtered and HTML strip out any javascript)

wayland’s picture

That doesn't work either.
Does anyone uses javascript directly into Drupal?

Is there anyway I can write this in an other way compatible with drupal?

This would do a great module showing this web site into a module : http://hypem.com/

<script type="text/javascript" language="JavaScript" src="http://hypem.com/playlist/time/today/js/1/hype.js"></script>

BooDy’s picture

This is probably a little bit late, You can create a new input format to use with with this block. I was trying to add a javascript to a block and all the input formats didn't work so I created a new input format and add no filters to this input format. This input format should work with javascript.

Ragmop’s picture

Go to Administer>Site Building. Choose "input formats." Create a title such as "allow javascript"

Now create a new block as usual and click the "Input format" to drop down the list. Choose your newly created input format. The rest is the same as usual.

mattrweaver’s picture

This worked for me, in Drupal 5.x. Thanks!

Finished products are for decadent minds. -- Isaac Asimov

Finished products are for decadent minds. -- Isaac Asimov

nurielmizrahi’s picture

It worked for me too! Thanks a lot!

zeal’s picture

Hi Ragmop

I m using drupal 5.x but it doesnt work for me.

Can u tel me how to add below javascript code in block and abt input filter.

if (Drupal.jsEnabled) {
  function changetitle(title_id) {
    alert("hi");
  }
}
zeal’s picture

yes it works now.......i can add javascript from new block.
Thanks :)

valthebald’s picture

Small correction: in D6 it's Admin / Site configuration / Input formats
http://www.valthebald.net

jhauer’s picture

New to Drupal. Considering switching sites from WP. Thanks for this great tip. Should make life so much easier. Happy to say I ran into this issue and solved it within minutes here. Awesome!

acacecec’s picture

I don't know how block support javascript, plz show me...

sofyanr’s picture

I get same problem. Any one can help us? How to add block with javascript code?

ehalber’s picture

I had this same issue a while ago and discovered that my script tags needed to look like this:

<script type="text/javascript">

// your code here

</script>

If I left out the type attribute or it was malformed, the javascript was not processed. This has to do with the xhtml doctype

http://www.bejoy.in/Techzone/Convert-html-to-xhtml

search for: "The type attribute is mandatory for all

tags. This value of type is text/javascript for Javascript."
nevets’s picture

Generally one should be adding JavaScript through one of the mechanisms provided by Drupal such as drupal_add_js or the 'script' section of a theme .info file

logeshvaran’s picture

I have used the javascript code inside a Block and chosen Input Text Format as "Full Html".

And the Javascript code is working fine.

But I want to know, whether its a good practice or not ?