0

I need to know what page i'm on based on the URL.

When i use $(location).attr('href')i get a very long url like this:

http://localhost:8181/research/gadgets/ifr?container=default&mid=0&nocache=0&country=ALL&lang=ALL&view=default&nerwVersion=~project.version~&url=http%3A%2F%2Flocalhost%3A8181%2Fresearch%2Fnerw-gadgets%2FCompanyDetails%2FCompanyDetails.xml&oaaParent=http%3A%2F%2Flocalhost%3A8181

The URL in the browser looks like this:

http://localhost:8181/research/?view=home

How do i get the view=home bit?

Andy
  • 503
  • 3
  • 15
  • 29

1 Answers1

0

Try This:-

function getQuerystring(name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(window.location.search);
        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }

    Usage getQuerystring("view");