-2

Could someone recommend a way to get page name from a url using JavaScript?

For instance if I have:

/suara/suaradata.php?page=$id

I just need to get "suaradata.php?page=$id" string

Thanks!

  • I could easily post an answer, but looking at the way things are going here, I'd probably get a -1, so I'll just ignore this question... – rodrigo-silveira Dec 02 '13 at 05:00

2 Answers2

-1

The simplest example:

var id, url='/suara/suaradata.php?page=344';
if (url.indexOf('page=')) id=url.split('=')[1];
crazyzubr
  • 1,072
  • 7
  • 14
-2
url= document.URL;
url = url.split('?');
par = url[1].split('=');

for(i=0; i < par.length; i=i+2){
alert(par[i]+"="+par[i+1]);
}
guest
  • 1
  • 1