admin管理员组文章数量:1401384
What I want to do is basically a div-Element containing the print-friendly version of Wikipedia articles. I used an iframe to embed articles and it works, though I cannot style the document. I guess this is because the iframe content is not on my domain and I do not have editing rights. Is there a way to apply css styling to the content after the iframe is loaded?
What I want to do is basically a div-Element containing the print-friendly version of Wikipedia articles. I used an iframe to embed articles and it works, though I cannot style the document. I guess this is because the iframe content is not on my domain and I do not have editing rights. Is there a way to apply css styling to the content after the iframe is loaded?
Share Improve this question edited Oct 26, 2014 at 20:41 celeritas 2,2811 gold badge19 silver badges28 bronze badges asked Oct 26, 2014 at 20:01 ifthisthenthatifthisthenthat 951 gold badge2 silver badges10 bronze badges 4- Download it with server-side script, modify paths to css and so on, insert the result into your page. – Cheery Commented Oct 26, 2014 at 20:03
- Thank you. Unfortunately I lack the knowledge to do the server side download. Would you use PHP for that? – ifthisthenthat Commented Oct 26, 2014 at 20:06
- PHP, Perl, Python, .. whatever you can run on server-side. Even by wget + bash – Cheery Commented Oct 26, 2014 at 20:06
- what about this embed.ly/provider/wikipedia (3rd party service) – andilabs Commented Oct 27, 2019 at 14:33
1 Answer
Reset to default 6You can do this with AJAX by calling the wiki api with custom query string parameters.
DEMO http://jsfiddle/fm0vxg32/
JS
$(document).ready(function(){
$.ajax({
type: "GET",
url: "http://en.wikipedia/w/api.php?action=parse&format=json&prop=text§ion=0&page=Jimi_Hendrix&callback=?",
contentType: "application/json; charset=utf-8",
async: false,
dataType: "json",
success: function (data, textStatus, jqXHR) {
var markup = data.parse.text["*"];
var blurb = $('<div></div>').html(markup);
$('#article').html($(blurb).find('p'));
},
error: function (errorMessage) {
}
});
});
CSS
#article {
// custom styling
}
本文标签: javascriptIs there a way to embed and style a Wikipedia article in a websiteStack Overflow
版权声明:本文标题:javascript - Is there a way to embed and style a Wikipedia article in a website? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744206591a2595218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论