2013-07-25 61 views
1

我想訪問一個JavaScript函數,但它是說它沒有聲明。我試圖設置訪問修飾符,並想知道如何在javascript中執行此操作。

下面是我試圖宣佈爲公共的功能。

訪問Javascript中的修飾符

<script language ="javascript" type ="text/javascript"> 
function PopupPicker(ctl, w, h) { 
    var PopupWindow = null; 
    settings = 'width=' + w + ',height=' + h + ',location=no,directories=no, menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no'; 
    PopupWindow = window.open(<%= getServerName.getserverName("/Quoteman/DatePicker.aspx?Ctl=") %>); 
    PopupWindow.focus(); 
}; 

編輯:這是我想調用的函數。

<asp:TextBox ID="DateInTxt" runat="server" Width="80px"></asp:TextBox><asp:ImageButton 
        ID="ImageButton1" runat="server" BorderStyle="None" ImageUrl="~/icons/vwicn063.gif" 
        OnClientClick="PopupPicker('DateInTxt', 250, 250);" Width="21px" /></td> 
+1

這個腳本與你的HTML有關嗎? – tymeJV

+0

低於標記。我也嘗試將它放在

標籤中。 – GeoffWilson

+0

你如何使用*函數?你從哪裏得到錯誤? – Pointy

回答

1

JavaScript中確實沒有訪問修飾符,因爲它是嵌套的作用域語言。閉包創建訪問修飾符的外觀,您可以在某些時間使某些功能可用於對象。

查看JavaScript Closures瞭解關於閉包在JavaScript中的工作方式。

+0

謝謝,這回答了我的問題。現在我的下一個問題是爲什麼它不識別我的功能? – GeoffWilson

+0

也許開始一個沒有提及訪問修飾符的新問題? –