Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Look up a word in Wiktionary via MediaWiki API and show the Wiktionary page
<script type="text/javascript" src="./jquery-1.4.3.min.js"></script>
<script type="text/javascript">
var baseURL = '';
function showPage(page,text) {
var sourceurl = baseURL + '/wiki/' + page;
// now you can modify content of #wikiInfo as you like
$('#wikiInfo').find('a:not(.references a):not(.extiw):not([href^="#"])').attr('href',
function() { return baseURL + $(this).attr('href');
// ...
$(document).ready(function() {
$('#word').change(function() {
var page = this.value;
$('#wikiInfo').html('...please wait...');
function(json) {
if(json.parse.revid > 0) {
} else {
$('#wikiInfo').html('word not found');
Lookup a word: <input type="text" id="word" />
<h1 id='pagetitle'></h1>
<div id="wikiInfo"></div>
<div id="licenseinfo" style="font-size:small; display:none;">
Modified original content <a id='sourceurl'>from Wiktionary</a>.
Text available under <a href="http:Content is available under the <a href="">Creative Commons Attribution/Share-Alike License</a>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment