Drag to your bookmarks bar ...">

Javascript in a Wordpress post

how can i add

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

in my Wordpress post.

I created a bookmarklet, and I want to transfer it through my blog. But Wordpress disables javascript from my post when it displays it.

+5
source share
2 answers

I have no problem embedding this code in the HTML editor on my wordpress site. There is a problem with your javascript code that defines a function but never calls it. I have

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

in the message, and I get a warning when I click, as well as a bookmarklet.

0
source

The problem is likely to be caused at the end of the browser. XSS Chrome was a problem for me, and I solved it by adding the header ("X-XSS-Protection: 0"); line header ("X-XSS-Protection: 0"); in wp-blog-header.php to the root folder of my installation. This may not be ideal, as it applies throughout the site. It would probably be better to add it where it will only apply to the post / page that should display the bookmarklet.

0
source

Source: https://habr.com/ru/post/957619/


All Articles