2014-01-29 3 views
2

Я разрабатываю для Windows Phone 8 App и я новичок в Windows Phone 8.WebBrowser.InvokeScript() Выдает Error: 80020006

Я использую WebBrowser Control и попытаться загрузить HTML страницу, имеющую JavaScript.

На событие button_Click я вызываю Webbrowser.InvokeScript («JavascriptFunctionName»), но он всегда выдает ошибку: 80020006, хотя WebBrowser.isScriptEnabled = true.

Ниже приведен код

Html Страница: MyHtmlPage.html

<!DOCTYPE html> 
<html> 
<head title="test"> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<style type="text/css"> 
    html { 
     height: 100%; 
    } 

    body { 
     height: 100%; 
     margin: 0; 
     padding: 0; 
    } 

    #map-canvas { 
     height: 100%; 
    } 
</style> 

<script type="text/javascript"> 
    function initialize() { 

     var helloText = document.getElementById("Hello"); 
     helloText.textContent = "Initialized"; 

     return ("Initialize"); 

    } 

</script> 
</head> 
<body> 
    <div id="test-canvas" /> 
    <label id="Hello">Hello</label> 
</body> 
</html> 

Cs Файл: MainPage.cs

private string TestUri = @"Html/Test.html"; 
private string stringHtml = string.Empty; 

public MainPage() 
{ 
    InitializeComponent(); 
    WebBrowser.IsScriptEnabled = true; 
    WebBrowser.IsGeolocationEnabled = true; 
} 

private void WebBrowser_Loaded(object sender, RoutedEventArgs e) 
{    
    var resource = App.GetResourceStream(new Uri(TestUri, UriKind.Relative)); 
    stringHtml = new StreamReader(resource.Stream).ReadToEnd(); 
    WebBrowser.NavigateToString(stringHtml); 
} 

private void Button_Click(object sender, RoutedEventArgs e) 
{ 
    try 
    { 
     //Error 
     string returnValue = WebBrowser.InvokeScript("initialize"); 
    } 
    catch(Exception ex) 
    { 
    } 

}

Помоги мне .. Спасибо.

+0

http://stackoverflow.com/questions/17466309/c-sharp-invokescript-gives-error-80020006 –

+0

@UweKeim, это не оно. Мы определили, что '

Смежные вопросы