私はこのコードを持っており、それは機能しています。
var URL = new Object();
URL.pattern = /https?:\/\/([^\/]*)\//;
URL.current = window.location.href;
URL.getCurrent = function(){
return this.current.match(this.pattern)[1];
};
var thisDomain = URL.getCurrent();
今私が欲しいのは、ドット表記をオブジェクトに入れることです。どうすればいいですか? これを試しましたが、URL.getCurrent() を呼び出すと undefined と表示されます。
function URL(){
this.pattern = /https?:\/\/([^\/]*)\//;
this.current = window.location.href;
this.getCurrent = function(){
return this.current.match(this.pattern)[1];
};
}
誰かが私を助けてくれることを願っています。