iframe wikipedia article without the wrapper

你。 提交于 2019-12-22 11:31:22

问题


I want to embed a wikipedia article into a page but I don't want all the wrapper (navigation, etc.) that sits around the articles. I saw it done here: http://www.dayah.com/periodic/. Click on an element and the iframe is displayed and links to the article only (no wrapper). So how'd they do that? Seems like JavaScript handles showing the iframe and constructing the href but after browsing the pages javascript (http://www.dayah.com/periodic/Script/interactivity.js) I still can't figure out how the url is built. Thanks.


回答1:


The periodic table example loads the printer-friendly version of the wiki artice into an iframe. http://en.wikipedia.org/wiki/Potasium?printable=yes

it's done in function click_wiki(e) (line 534, interactivity.js)

var article = el.childNodes[0].childNodes[n_name].innerHTML;
...
window.frames["WikiFrame"].location.replace("http://" + language + ".wikipedia.org/w/index.php?title=" + encodeURIComponent(article) + "&printable=yes");



回答2:


@VolkerK is right, they are using the printable version.

Here is an easy way to find out when you know the site is displaying the page in an iframe.

In Firefox right click anywhere inside the iframe, from the context menu select "This Frame" then "View frame info"

You get the info you need including the Address:

Address: http://en.wikipedia.org/w/index.php?title=Chromium&printable=yes




回答3:


The jQuery library lets you specify part of a page to retrieve by an Ajax call, with a CSS-like syntax: http://docs.jquery.com/Ajax/load




回答4:


You could always download the site and scrap it. I think everything inside <div id="bodyContent"> is the content of the article - sans navigation, header, footer, etc..

Don't forget to credit. ;)



来源:https://stackoverflow.com/questions/61902/iframe-wikipedia-article-without-the-wrapper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!