Current Page with JavaScript

0
0

This is like a replacement for PHP’s SCRIPT_NAME with JavaScript.

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

For example with this URL:
http://css-tricks.com/examples/ScriptName/index.php

This code:

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

Would write to the page: “index.php”

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.