Title: java script side widget problem
Last modified: August 31, 2016

---

# java script side widget problem

 *  Resolved [passegua](https://wordpress.org/support/users/passegua/)
 * (@passegua)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/)
 * I’ve been suggested to use this plugin in order to solve the issue you can read
   [here](https://wordpress.org/support/topic/java-script-side-widget-problem?replies=3#post-7938648).
 * Could I use it in a side widget?
 * Many thanks.
 * [https://wordpress.org/plugins/custom-css-js/](https://wordpress.org/plugins/custom-css-js/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989544)
 * Of course you can use the plugin to add the necessary javascript to the website.
   You will just have to consider that the javascript will be shown on the whole
   frontend, not only on the pages that use the widget.
 *  Thread Starter [passegua](https://wordpress.org/support/users/passegua/)
 * (@passegua)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989589)
 * thanks Diana for the reply.
    due to my poor English I do not understand if this
   plugin allows me to write javascript code into the widget itself. best regards
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989649)
 * Yes, you can use the plugin to write the Javascript code on the website.
 *  Thread Starter [passegua](https://wordpress.org/support/users/passegua/)
 * (@passegua)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989666)
 * I understand: “I can use the plugin to write the Javascript code on the website.”
 * But I kindly wish to know if I can use the plugin to write the Javascript code
   into a side widget. If yes, how?
 * How could I can use the plugin to write the Javascript code inside a widget?
 * Many thanks for your patience.
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989668)
 * You cannot write javascript code directly inside a widget, but you can modify
   the javascript code in order to have the same effect. Essentially this is also
   what the forum moderator was suggesting.
 * For example, the following code:
 *     ```
       <!--  ADVERTISEMENT TAG 160 x 600, DO NOT MODIFY THIS CODE -->
       <script type="text/javascript">
       <!--
       document.write('<iframe marginheight="0px" marginwidth="0px" frameborder="0" scrolling="no" width="160" height="600" src="http://optimized-by.simply.com/play.html?code=170107;61415;57339;0&from='+escape(document.referrer)+'"></iframe>');
       // -->
       </script>
       ```
   
 * you can rewrite as follows:
 *     ```
       jQuery(window).ready(function($){
         $('.element-class').html('<iframe marginheight="0px" marginwidth="0px" frameborder="0" scrolling="no" width="160" height="600" src="http://optimized-by.simply.com/play.html?code=170107;61415;57339;0&from='+escape(document.referrer)+'"></iframe>');
       }
       ```
   
 * where `element-class` is the CSS class of the widget were you want the code to
   show up.
 * With Simple Custom CSS and JS you can add the rewritten code and it should have
   the same effect.
 * I know this doesn’t sound like the easiest solution, but there is a reason for
   which they remove the javascript code from widgets.
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989669)
 * The second code you can rewrite as follows:
 *     ```
       jQuery(window).ready(function($){
       simply_publisher = 57339;
       simply_domain = 61415;
       simply_space = 170107;
       simply_ad_height = 600;
       simply_ad_width = 160;
       simply_callback = '';
   
       var cb = Math.round(new Date().getTime());
       $('.element-class').html('<scr'+'ipt type="text/javascript" src="'+ ('https:' == document.location.protocol ? 'https://' : 'http://') + 'optimized-by.4wnetwork.com/simply_loader.js?cb='+ cb +'"></scr' + 'ipt>');
       }
       ```
   
 * where, again, the `element-class` is the CSS class of the widget were you want
   the code to show up.
 * Let me know if this works.
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989670)
 * Sorry, you also need to add an `);` at the end of each code snippet I gave you.
 * Like this:
 *     ```
       jQuery(window).ready(function($){
         $('.element-class').html('<iframe marginheight="0px" marginwidth="0px" frameborder="0" scrolling="no" width="160" height="600" src="http://optimized-by.simply.com/play.html?code=170107;61415;57339;0&from='+escape(document.referrer)+'"></iframe>');
       });
       ```
   
 * and
 *     ```
       jQuery(window).ready(function($){
       simply_publisher = 57339;
       simply_domain = 61415;
       simply_space = 170107;
       simply_ad_height = 600;
       simply_ad_width = 160;
       simply_callback = '';
   
       var cb = Math.round(new Date().getTime());
       $('.element-class').html('<scr'+'ipt type="text/javascript" src="'+ ('https:' == document.location.protocol ? 'https://' : 'http://') + 'optimized-by.4wnetwork.com/simply_loader.js?cb='+ cb +'"></scr' + 'ipt>');
       });
       ```
   
 *  Thread Starter [passegua](https://wordpress.org/support/users/passegua/)
 * (@passegua)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989675)
 * So you mean that:
    1) I install the plugin (any special setting?) 2) I write 
   the modified code into a widget
 * and that’s all?
 * It sounds very simple!
 * I don’t have to set the plugin in order to make this widget code works?
 * I’ll try asap. Thanks
 *  Thread Starter [passegua](https://wordpress.org/support/users/passegua/)
 * (@passegua)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989682)
 * Bad luck!
 * I cannot activate this plugin!
 * > The plugin can not be activated because a fatal error.
   > Parse error: syntax error, unexpected ‘[‘ in /web/htdocs/www.sinapsi.org/home/
   > wordpress/wp-content/plugins/custom-css-js/custom-css-js.php on line 71
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989684)
 * Oh, your server is using an older version of PHP (<=3). I updated the code so
   it doesn’t throw that error.
 * But you understood it wrong. You activate the plugin and write the modified javascript
   code in the “Add new JS” section of the plugin, as shown in the [screenshot](https://s.w.org/plugins/custom-css-js/screenshot-2.jpg?r=1338823).
 * Also you need to change the `element-class` from the modified code with the CSS
   class of the widget.
 *  Thread Starter [passegua](https://wordpress.org/support/users/passegua/)
 * (@passegua)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989688)
 * The plugin still generate a fatal error:
 * >  Parse error: syntax error, unexpected ‘[‘ in /web/htdocs/www.sinapsi.org/home/
   > wordpress/wp-content/plugins/custom-css-js/custom-css-js.php on line 266
 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989703)
 * I’m sorry, please try again to uninstall and install/activate the plugin.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘java script side widget problem’ is closed to new replies.

 * ![](https://ps.w.org/custom-css-js/assets/icon-128x128.png?rev=1303730)
 * [Simple Custom CSS and JS](https://wordpress.org/plugins/custom-css-js/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-css-js/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-css-js/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-css-js/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-css-js/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-css-js/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [widget](https://wordpress.org/support/topic-tag/widget/)

 * 12 replies
 * 2 participants
 * Last reply from: [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/java-script-side-widget-problem-1/#post-6989703)
 * Status: resolved