我正在使用不允许我直接编辑某些部分的软件。作为一种变通方法,我可以将js添加到页眉/页脚来编辑这些部分。我想把我的twitter feed从一个部分移到另一个部分,但是当我这样做的时候,iframe中的HTML就丢失了。我相信这与iframe没有重新加载有关。但是,当我在jsfiddle中执行此操作时,它确实可以工作。http://jsfiddle.net/u8kt067s/
<div class="editable">
<p>This content can be edited directly using html</p>
<a class="twitter-timeline" href="https://twitter.com/Jenny_Lane4" data-widget-id="646719649313374208">Tweets by @Jenny_Lane4</a>
</div>
<div class="cantedit">
<p>This content cannot be edited directly, you must use a script.
This is where I would like the twitter feed to appear</p>
</div>
任何帮助都将不胜感激!
发布于 2015-09-24 00:49:26
在移动div之后,您必须重新加载twitter脚本。
$(function(){
$('.twitter-timeline').appendTo('div.cantedit');
reload();
});
function reload(){
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");}
看看这个小提琴:http://jsfiddle.net/x2vb3L0j/
https://stackoverflow.com/questions/32744959
复制相似问题