Share via


BrowserInteropHelper.HostScript Özellik

Tanım

XAML tarayıcı uygulaması (XBAP) bir çerçevede barındırılıyorsa HTML penceresi nesnesine, özel betik işlevlerine ve HTML sayfası için genel değişkenlere erişim sağlayan bir betik nesnesi alır.

public:
 static property System::Object ^ HostScript { System::Object ^ get(); };
public static dynamic HostScript { [System.Security.SecurityCritical] [System.Security.SecurityTreatAsSafe] get; }
public static dynamic HostScript { get; }
[<get: System.Security.SecurityCritical>]
[<get: System.Security.SecurityTreatAsSafe>]
static member HostScript : obj
static member HostScript : obj
Public Shared ReadOnly Property HostScript As Object

Özellik Değeri

XAML tarayıcı uygulaması (XBAP) bir çerçevede barındırılıyorsa HTML penceresi nesnesine, özel betik işlevlerine ve HTML sayfası için genel değişkenlere erişim sağlayan bir betik nesnesi; aksi takdirde , null.

Öznitelikler

Örnekler

Aşağıdaki örnekte, nesnesinin nasıl alınıp HostScript tarayıcı penceresinin kapatılma işlemi gösterilmektedir.

<Grid>
   <Button Width="160" Height="60" Click="Button_Click" Content="Close Browser Window" />
 </Grid>
private void Button_Click(object sender, RoutedEventArgs e)
{
    // Retrieve the script object. The XBAP must be hosted in a frame or
    // the HostScript object will be null.
    var scriptObject = BrowserInteropHelper.HostScript;

    // Call close to close the browser window. 
    scriptObject.Close();
}
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    ' Retrieve the script object  The XBAP must be hosted in a frame or
    ' the HostScript object will be null.
    Dim scriptObject = BrowserInteropHelper.HostScript

    ' Call close to close the browser window.
    scriptObject.Close()
End Sub

Açıklamalar

Döndürülen HostScript nesne ile HTML pencere nesnesinin özelliklerine, yöntemlerine ve olaylarına erişebilir, doğrudan bir betik işlevi çağırabilir veya genel değişkene erişebilirsiniz. Bu öğelere erişmek için kullanılan söz diziminde tanıdık nokta gösterimi kullanılır.

Pencere nesnesi hakkında daha fazla bilgi için bkz. Pencere.

Özellik HostScript , çerçeve etki alanları arası bir konumdan gidilirse döndürür null .

Bu özellik, ScriptInteropDisallow kayıt defteri değeri ayarlanarak tarayıcı için kapatılabilir. Daha fazla bilgi için bkz . Güvenlik (WPF).

Şunlara uygulanır