10 examples of 'javascript get current domain' in JavaScript

Every line of 'javascript get current domain' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
109function getDomain() {
110 return [ new Date() - time.MINUTE * 5, new Date().getTime() ];
111}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

3function viewDomain() {
4 var domain = this.href.split('#')[1];
5 var tld = domain.split('.')[1];
6
7 $('.info .domain').text(domain);
8 randomTweet();
9
10 for(reg in registrars) {
11 if(registrars[reg].tlds.indexOf(tld) > -1) {
12 link = registrars[reg].link.replace('{{d}}', domain);
13 $('.reg.' + reg).addClass('true');
14 $('.reg.' + reg).attr('href', link);
15 $('.reg.' + reg).attr('target', '_blank');
16 }
17 else {
18 $('.reg.' + reg).removeClass('true');
19 $('.reg.' + reg).attr('href', 'javascript:void(0)');
20 $('.reg.' + reg).attr('target', '_self');
21 }
22 }
23
24 $('.info').css({display: 'block'});
25 $('.info-bg').css({display: 'block'});
26
27 setTimeout(function() {
28 $('.info').css({opacity: 1});
29 $('.info-bg').css({opacity: 0.3});
30 }, 0);
31}
23function getDomain(url){
24 var t=url.split('://')[1];
25 return t.split('/')[0];
26}
40get domain(): string[] {
41 return _private.get(this).domain;
42}
15function getDomains(){
16 $.getJSON('/api/v1/domains?rand='+Math.random(), function(data) {
17 var items = [];
18
19 $.each(data.domains, function(key, val) {
20 items.push('<b>Domain:</b> <a href="http://' + val.name + '">'+val.name+'</a> -- <b>IP:</b> '+ val.ipaddress +' -- <b>Last Update:</b> <abbr class="timeago" title="'+val.updated+'">'+ new Date(val.updated).toLocaleString() +'</abbr> -- <button onclick="downloadTask(\''+val.name+'\')">download client</button> -- <button onclick="deleteDomain(\''+val._id+'\')">delete domain</button><hr>');
21 });
22
23 $('#container > div').empty();
24
25 $('<ul/>', {
26 'class': 'my-new-list',
27 html: items.join('')
28 }).appendTo('#container > div');
29
30 $("abbr.timeago").timeago();
31
32 });
33}
151function getDomain(referer) {
152 if (referer) {
153 let domainA = document.createElement('a');
154 domainA.href = referer;
155 return domainA.hostname;
156 }
157}
66export default function topDomain(url) {
67 const levels = getLevels(url);
68
69 // Lookup the real top level one.
70 for (let i = 0; i < levels.length; ++i) {
71 const cname = '__tld__';
72 const domain = levels[i];
73 const opts = {
74 domain: `.${domain}`,
75 };
76 cookie.set(cname, 1, opts);
77 if (cookie.get(cname)) {
78 cookie.set(cname, null, opts);
79 return domain;
80 }
81 }
82
83 return '';
84}
115setDomain (){
116 return this.settings.domain;
117}
6function get_code(domain_name,callback){
7 var code = 404;
8 request(api_url + domain_name, function (error, response, body) {
9 if(!error && response.statusCode == 200 && body){
10 code = body.match(/\<original\>(.+)\:/)?parseInt(body.match(/\<original\>(.+)\:/)[1]):404;
11 }
12 callback({
13 'url' : domain_name,
14 'code' : code
15 })
16 });
17}
135get domain () {
136 return getDomain(this.url)
137}

Related snippets