Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Ruby
Posted by: petecocoon
Added: Jan 4, 2013 10:43 AM
Modified: Jan 4, 2013 10:44 AM
Views: 96
  1. #put it in your application helper  
  2. def safe_js_print html
  3.     string = ''
  4.    "document.write('#{html}');".each_byte do |c|
  5.       string << sprintf("%%%x", c)
  6.     end
  7.     "<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>".html_safe
  8.   end