Add Javascript code to WordPress page
-
Hello everyone! I am trying to add a simple Javascript snippet to my page using the html editor but it doesn’t seem to work.
the code is the following:var a = 5;
alert(‘The value of a is: ‘ + a);The result that I get is:
alert(‘The value of a is: ‘ + a);
written in the page, which means that the Javascript code did not execute.
Any help would be greatly appreciated (please no plug-in solutions as I have a free wordpress account)
The blog I need help with is: (visible only to logged in users)
-
That code won’t work on a free plan I’m afraid. You would need to upgrade to the Business plan for that functionality. https://en.support.wordpress.com/code/
PS: Why do you require an alert popup? Further details about this may allow someone else in the forum to offer other solutions. -
Thank you very much for your reply. The snippet was just an example to make sure Javascript actually worked. I actually wanted to create a google map with multiple pins using Javascript so that I would be able to customize it. But as I saw it is impossible. As I read on the link you sent me, the premium members cannot use Javascript as well so the only option is Business Plan.
-
I believe you can use Google maps on a WordPress.com free plan. The iframes are converted to shortcode. See here: https://en.support.wordpress.com/google-maps/
-
I will try it this way until I upgrade to business plan. Thank you very much for your help themagicrobot!
- The topic ‘Add Javascript code to WordPress page’ is closed to new replies.