Wikipedia:WikiProject User scripts/Scripts/Get Page Name

This is an old revision of this page, as edited by Raylu (talk | contribs) at 01:22, 14 August 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Returns the name of the page. For example, if you were browsing the "foo" WP page, getPname() would return "foo".

function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") return z[n].textContent;
  };
}

This code was taken from the LastDiff code.