Trenutna stran z JavaScriptom - CSS-triki

Anonim

To je kot zamenjava za PHP SCRIPT_NAME z JavaScriptom.

location.href.split('/').pop();

Na primer s tem URL-jem:
https://css-tricks.com/examples/ScriptName/index.php

Ta koda:

document.write( location.href.split('/').pop() );

Bi napisal na stran: "index.php"