我有這個代碼,它的工作。如何將這個結合到一個JavaScript對象?
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];
};
}
我希望有人能幫助我。
另外,我希望你至少勾選一個答案這個時候 – Alexander 2012-08-01 06:41:15
對不起你們,我不知道。我從現在開始接受他們。 =) – reitermarkus 2012-08-01 06:57:58