Wikipedia:WikiProject User scripts/Scripts/Get Page Name: Difference between revisions

Content deleted Content added
JesseW (talk | contribs)
m linking source of the code
No edit summary
 
(11 intermediate revisions by 9 users not shown)
Line 1:
/*<pre>*/
/*Returns the name of the page. For example, if you were browsing the "[[foo]]" WP page, getPname() would return "foo".*/
 
<pre><nowiki>
function getPname() {
return mw.config.get('wgPageName').replace(/_/g, ' ');
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") return z[n].textContent;
};
}
/*</pre>[[Category:Wikipedia scripts]]*/
</nowiki></pre>
 
This code was taken from the [[Wikipedia:WikiProject User scripts/Scripts/Show last diff|Show last diff]] code.