whateverorigin 运行 html 代码

whateverorigin run html code

我正在尝试 运行 iframe 中使用任何来源的小型应用程序:

    <script>
    $.getJSON('http://whateverorigin.org/get?url=' +      
    encodeURIComponent('http://vend.giftcardservices.nl/saldo/3') + 
    '&callback=?', function(data){
    alert(data.contents);
    });
    </script>   

并且警报显示 html 已提取,但是当我尝试 document.write(data.contents) 时,没有任何反应。如何让这段代码在浏览器中执行?

您已经在使用 jQuery,don't use document.write。相反,使用

$(document.body).append(data.content);

如果您要将内容加载到特定元素中,您可以使用

$('#selector').html(data.content);

这是片段

$.getJSON('http://whateverorigin.org/get?url=' +      
    encodeURIComponent('http://vend.giftcardservices.nl/saldo/3') + 
    '&callback=?', function(data){
    $(document.body).append(data.contents.replace('/static/js/saldo.js', 'http://vend.giftcardservices.nl/saldo/3/static/js/saldo.js'));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>