最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - iframe wikipedia article without the wrapper - Stack Overflow

programmeradmin5浏览0评论

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: /. 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 (.js) I still can't figure out how the url is built. Thanks.

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./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./periodic/Script/interactivity.js) I still can't figure out how the url is built. Thanks.

Share Improve this question asked Sep 15, 2008 at 5:28 mrjrdnthmsmrjrdnthms 1,6294 gold badges25 silver badges35 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 16

The periodic table example loads the printer-friendly version of the wiki artice into an iframe. http://en.wikipedia/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/w/index.php?title=" + encodeURIComponent(article) + "&printable=yes");

@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/w/index.php?title=Chromium&printable=yes

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

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. ;)

发布评论

评论列表(0)

  1. 暂无评论