English 中文(简体)
OO Javascript. 财产
原标题:OO Javascript. Properties Issue
  • 时间:2011-11-14 21:37:34
  •  标签:
  • javascript

我来自OOP语言(Java、C#和PHP)。 我只是在 Java文中做一些OOP,在如何界定财产方面被严重混淆。 下面的法典以“希尔马”法为根据,与“我”合作一样。 我也提到了我认为应宣布财产的方式,但似乎没有工作。

var myExtension = {

    // This is how I thought it d be done
this.instructionServers = new Array(
    "http://server.com/json.php",
),


init: function() {  
    // The event can be DOMContentLoaded, pageshow, pagehide, load or unload.  
    if(gBrowser) {
        gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad,false);  
    }
},  

onPageLoad: function(aEvent) {  
    var doc = aEvent.originalTarget; // doc is document that triggered the event  
    var win = doc.defaultView; // win is the window for the doc  

    // Skip frames and iFrames
    if (win.frameElement) return;

    // Code removed
}  
问题回答

各位

var myExtension = {
    instructionServers: ["http://server.com/json.php"],

    // ...

};

或者,你也可以直接分配 Java的房产,就像在,里。

myExtension.instructionServers = ["http://server.com/json.php"];

这将使<代码>instructionServers成为myExtension的一系列财产。 那么,你就可以获得财产价值。

myExtension.instructionServers

myExtension[ instructionServers ]

只是指出,在 Java,你可以使用手法。

[ hello , 3]

is equivalent to the m或e verbose and discouraged

new Array( hello , 3)
var myExtension = {
        url:  http://server.com/json.php ,
        init: function() {
            alert( 页 次.url );
        }
}

myExtension.init();

从技术上来说,财产本身只是一种类型功能的财产。 宣布扼杀性财产只是确定一种与上述相同的方式。

提及贵物体内的财产

页 次

你们正在使用标语(ink子),因此,不应“=”。

指示Servers: [http://server.com/json.php],





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签