Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript in a WordPress post

How can I add

<a href="javascript:function foo(){alert('hi');}" title="alert">
    Drag to your bookmarks bar
</a>

to my WordPress post?

I built a bookmarklet and I want to pass it through my blog, but WordPress is stripping out the javascript from my post when I save it.

like image 840
codeAnand Avatar asked Jul 04 '26 14:07

codeAnand


1 Answers

Javascript in WordPress Single Pages and Posts

<script type="text/javascript">
<!--
// your code
//--></script>

Source: https://codex.wordpress.org/Using_Javascript

like image 159
DanOPT Avatar answered Jul 06 '26 04:07

DanOPT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!