java script side widget problem
-
I’ve been suggested to use this plugin in order to solve the issue you can read here.
Could I use it in a side widget?
Many thanks.
-
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.
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 regardsYes, you can use the plugin to write the Javascript code on the website.
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.
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-classis 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.
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-classis the CSS class of the widget were you want the code to show up.Let me know if this works.
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>'); });So you mean that:
1) I install the plugin (any special setting?)
2) I write the modified code into a widgetand 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
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
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.
Also you need to change the
element-classfrom the modified code with the CSS class of the widget.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
I’m sorry, please try again to uninstall and install/activate the plugin.
The topic ‘java script side widget problem’ is closed to new replies.