Jump to content

url parameters


adamriley

Recommended Posts

not perfect but works

 

<script>
function getParam(name) {
var url = location.href;

    if (url.indexOf('?') !== -1) {
        var query = url.substring(url.indexOf('?')+1, url.length);
        parts = query.split('&');
        for(i=0;i<parts.length;i++) {
            eachpart = parts[i].split("=");
            if (eachpart[0] == name) {
                return eachpart[1];
            }
        }
    }
}

document.write(getParam('name'));
</script>

Link to comment
https://forums.phpfreaks.com/topic/186283-url-parameters/#findComment-983806
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.