How can I add an IFRAME with javascript to ajax refreshed content ? Let's say I have something like this:
$('#bar').delegate('.scroll-content-item span a', 'click', function() {
var object_id = $(this).parent().attr("class");
$.ajax({
type: "POST",
url: "/myfunction.php",
data: "action=object_id=" + object_id,
dataType: "json",
success: function(data){
$('.info').html(data['html']);
}
});
return false;
});
So I've tried adding this code on success :
document.write('<IFRAME vspace=0 height=71 style="padding:10px" marginHeight=5 src="" frameBorder=0 width=54 name="pliggit" scrolling=no><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:"b24b6378-26a9-435c-ac5f-8aee4f59529c"});</script></IFRAME&开发者_如何学运维gt;');
But I'm getting Unterminated string literal
.
it's still early, but have you tried quoting your attributes?
or you could create your iframe in javascript:
var iframe = document.createElement('iframe');
iframe.setAttribute('vspace', '0');
etc.. ?
It doesn't like the </script>
tag. I'm still looking for a js answer to encode a block of code so that Javascript doesn't barf.
精彩评论