Jump to content
Sign in to follow this  
chrisyates

Why can't I just add JS to my sidebar?

Recommended Posts

chrisyates

I'm really struggling to understand why I cannot paste JS straight into one of my sidebar widgets and get it working. Here's what I do: Dragged a text widget to the drag_drop_sidebar Added a title to the text widget Pasted code into the body area of the text widget You can't really get any simpler than that but everytime I do this it doesn't work. I have now tried 3 different JS codes. Here's the latest: `Get the iTunes App Store widget and many other great free widgets at Widgetbox! Not seeing a widget? (More info)`

Share this post


Link to post
Share on other sites
cmunns

This is strange as other customers don't have this issue when trying to do the same thing. Have you tried adding the javascript to another area of the site to see if it's the script itself, your server setup, or the actual sidebar?

Share this post


Link to post
Share on other sites
chrisyates

Hi Adam, I have tried to add Google Adsense after a post but still have the same problem. The strange thing (after saving it) is, it takes me to a 404 error page on my site saying that it is unable to find the file?! As soon as I remove the JS code and click on save, it all works perfectly. I'm now wondering if this is a server set up issue but everything else works fine. I'm not even sure how I would explain it to my hosting company. I'm sure they would just say it's a problem with the theme or WP issue. Is there something I am missing? For example should I be removing or adding something before the code after pasting it?

Share this post


Link to post
Share on other sites
Andrew

does it work well in other areas of your site?

Share this post


Link to post
Share on other sites
chrisyates

No, it doesn't work anywhere. No matter where I put the JS code it doesn't want to know. I've used the AdsenseOptimizer plugin to add Google Adsense to the site and the ads show fine (which has obviously added the Adsense code Javascipt) but whenever I try to add JS by copying and pasting it doesn't want to know.

Share this post


Link to post
Share on other sites
cmunns

So the problem is only apparent when you are copying the code into the page? That is strange. Is their a plugin you could use to avoid copy/pasting as with the other one? Also I noticed there is this link from the code above http://docs.widgetbox.com/using-widgets/installing-widgets/why-cant-i-see-my-widget Have you visited that site or searched why your JS causes a 404?

Share this post


Link to post
Share on other sites
chrisyates

After tearing my hair out trying to figure this out, I found a solution. The most important JS I needed to add was a web stat code that allowed me to see which search terms were used and the site my visitors came from. In the end I just grabbed the footer.php using ftp added the code that way and re-uploaded it using ftp, works great! I still have no understanding why it won't work through WP. Doesn't solve my problem adding JS to the sidebar but hey, I'm half way there. Thanks for the previous advice guys.

Share this post


Link to post
Share on other sites
rockyrockwood

Sounds like an ongoing problem I've had with WP 'safety' mechanism stripping out java and other scripting from sidebar, posts, etc. Super lame...and buggy too... If I paste and save in just the right order it can work...but heaven forbid I need to open the widget up again. I did notice a wp plugin to kill java code stripping.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×