In WordPress when i publish a page with JS code is ignored and don’t returns anything.
How can I make sure that when I write a HTML+JS code will be converted to output?!
Like: <a class="print" href="#" onClick="window.print();">PRINT</a>
Thank you! and sorry for my weak english!
onclick
is not i the list of allowed attributes. It will be removed by kses. You can filter the list, use Extend KSES for example.I just tried this in a post of the latest WP install:
This seemed to work fine.
You will probably encounter that if you have any lengthily code for javascript that maybe then you should put that code into a file and point to it in the post/page. Like so:
But one other note. I generally do not want this …. If a site or a page needs to have some javascript added then maybe you need to ask yourself why.
IMHO for javascript and anything that can be lengthily in nature I would prefer to write a plugin.
I think you are entering this code in WYSIWYG Editor and not in HTML.
Everything you enter in HTML view is rendered and everything you enter in WYSIWYG Mode is displayed as you type.
For example
<a href=”http://wordpress.org”>WordPress</a>
will become WordPress