So I had to do a widget that will be shown’s on user of our website through js. I came across many articles that were dealing with it like Xss Widgets and
some posts that were very vague. Gladly, my friend from http://webalgorithm.com explained to me this whole ordeal in a very simple steps.
So this is what we want to do.
<script type="text/javascript" src="http://localhost:9090/monozub/widget.js"></script>
document.write('<b>some html</b>');
map.with_options :controller => 'widget' do |m|
m.facebook ':username/widget', :action => 'show'
m.widget_js ':username/widget.js', :action => 'show',:format => "js"
end
class WidgetController < ApplicationController
def show
#whatever logick you have goes here.
respond_to do |format|
format.html
format.js
end
end
end
<% 3.times do |i| %>
document.write('<b>Test <%= i %></b><br />');
<% end %>
Thats it folks, no need for JASON, XSS or any other high level technologies.
NOTE: be aware IE will give you a warning, but WHO USES THAT c…p Anyway :)