Hello,

I would like to include a Javascript code in a block.
First a Javascript function definition:

--scrit--... --scrit--

then --a href=\'javascrit:...--- call
Which would be the best way to do it? That is, ensuring security in the whole site and avoidng Javascript restrictions in that block.

Thank you!

Comments

tatonca’s picture

... then just echo the href

echo("<a href=\"java script:blah();\">...");

unless I am misunderstanding this, or you've already tried and it didn't work...

I'm assuming that for some reason just putting what you want in your custom block isn't working?

If this doesn't help you solve your problem, could you add a little more detail about what you've already tried and why it didn't work/what the error was? That would give us some more insight into your situation.

...and could someone else explain why the word javascript is filtered within a <code> tag? Doesn't it all get rendered inert in a code block anyway? Just curious...

Thanks

~Tat~

phatPhrog’s picture

Just create a new input format and set it as unfiltered.

Create a block and assign it the unfiltered format and you'll be set. Be sure to set the permissions on who you want to allow this format, too.

flipe’s picture

It was quite easy this way... Thank you!

phatPhrog’s picture

No problem. Glad it worked for you.

trohrer’s picture

Don't forget to surround it in code tags or it still won't work: e.g.

code /* start tag here */
<?php echo("<a href = \"javascript:window.print()\" title=\"Print this page\">print this page</a>");?>
/code /* close code tag here */