Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add a JavaScript widget to a Wordpress.com hosted blog?

I've got a site that provides blog-friendly widgets via JavaScript. These work fine in most circumstances, including self-hosted Wordpress blogs. With blogs hosted at Wordpress.com, however, JavaScript isn't allowed in sidebar text modules. Has anyone seen a workaround for this limitation?

like image 561
Ben Scofield Avatar asked Sep 17 '08 09:09

Ben Scofield


People also ask

Can I use JavaScript in WordPress?

Contents. JavaScript will work within WordPress. If used within the template files, most JavaScript will work fine. Here are a few tips to make your JavaScript work in WordPress.

How do I add HTML CSS and JavaScript to WordPress?

Go to Appearance -> Customize. In the customizer, there is an option for 'Additional CSS'. Click on that and add all the CSS you need and save. This is by far the easiest way to add custom CSS to your theme.


1 Answers

you could always petition wp to add your widget to their 'approved' list, but who knows how long that would take. you're talking about a way to circumvent the rules they have in place about posting arbitrary script. myspace javascript exploits in particular have increased awareness of the possibility of such workarounds, so you might have a tough time getting around the restrictions - however, here's a classic ones to try:

put the javascript in a weird place, like anywhere that executes a URL. for instance:

<div style="background:url('javascript:alert(this);');" />

sometimes the word 'javascript' gets cut out, but occasionally you can sneak it through as java\nscript, or something similar.

sometimes quotes get stripped out - try String.fromCharCode(34) to get around that. Also, in general, using eval("codepart1" + "codepart2") to get around restricted words or characters.

sneaking in javascript is a tricky business, mostly utilizing unorthodox (possibly un-documented) browser behavior in order to execute arbitrary javascript on a page. Welcome to hacking.

like image 82
matt lohkamp Avatar answered Nov 15 '22 21:11

matt lohkamp