开发者

How to add IFRAME with javascript to ajax loaded content

开发者 https://www.devze.com 2023-01-29 01:19 出处:网络
How can I add an IFRAME with javascript to ajax refreshed content ? Let\'s say I have something like this:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消