Thank Valdir for the answer!
After asking a question, I do my own research and end up with code:
window.onload = function() { httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { if (httpRequest.readyState !== 4) { console.log("Not ready, code: %o", httpRequest.readyState); return; } if (httpRequest.status !== 200) { console.log("Server error: %o", httpRequest.status); return; } var json = JSON.parse(httpRequest.responseText); console.log("json: %o", json); var wiki = json.query.pages["1"].revisions[0]["*"]; console.log("wiki: %o", wiki); var html = InstaView.convert(wiki); console.log("html: %o", html); document.getElementById('area').innerHTML = html; }; var url = 'https://wiki.evil-company.com/api.php?action=query&prop=revisions&format=json&titles=Main_page&rvprop=timestamp|user|comment|content'; httpRequest.open('GET', url, true); httpRequest.send(null); }
Here I use the https://github.com/cscott/instaview/blob/master/main.js project, which is extended by http://en.wikipedia.org/wiki/User:Pilaf to convert json output to HTML on the side browser.
The reason for this code is because our wiki is old or incorrectly configured and action = render is not available. But I am trapped in the cross-domain scripting problem, so I think that an iframe with action = render is the best solution.
See also. How do you grab an article, including links in an easy-to-use format?
Another suggestion to use action = parse ( http://en.wikipedia.org/w/api.php?action=parse&title=Linux ) leads to a warning:
You are looking at the HTML representation of the XML format. HTML is good for debugging, but is unsuitable for application use. Specify the format parameter to change the output format.
UPDATE
The perfect solution is simply adding an action = render request to any valid wiki url, for example:
http://en.wikipedia.org/wiki/Linux?action=render
source share