Javascript - Domain Adı ve Port Numarası Alma (Get DomainName - Get PortNumber)


function GetDomainNameFromUrl() {
    var url = window.location.href;
    var url_parts = url.split('/');

    var domain_name_parts = url_parts[2].split(':');
    var domain_name = domain_name_parts[0];
    return domain_name;
}

function GetPortNumberFromUrl() {
    var url = window.location.href;
    var url_parts = url.split('/');

    var domain_name_parts = url_parts[2].split(':');
    var port_number = domain_name_parts[1];
    return port_number;
}

Hiç yorum yok:

Yorum Gönder