从 MainPage 在托管页面上调用 javascript

Calling javascript on hosting page from MainPage

我有一个 Lync 的 CWE(对话 Window 扩展)。当我的 CWE 加载时,我希望在托管页面上调用 javascript。

public MainPage()        
{            
 try            
 {
   HtmlPage.RegisterScriptableObject("MainPage", this);  
   HtmlPage.Window.Invoke("callmeonPageLoad");          
 }            
 catch (Exception ex)            
 {                
   MessageBox.Show(ex.Message + "|" + ex.InnerException);            
 }            
}

callmeonPageLoad 看起来像这样

function callmeonPageLoad() {        
            if (typeof jQuery == 'undefined') {
                alert("jQuery is not loaded")
            } else {
                alert("jQuery is loaded")
            }
        }

如果我 运行 Lync jQuery 之外的这个应用程序被加载。 在应用程序内部它不会。所以,我不能调用任何 jQuery 函数。仅当我希望在加载页面时调用它(从 MainPage 调用)时才有效。

如果我在 Silverlight 应用程序中实现一个按钮并使其调用相同 javascript。 jQuery 已加载两种情况。

我的问题是如何在加载应用程序时调用包含 jquery 的 javascript。

做了更多调查,发现即使是这样的页面(设置为 CWE)也不会加载 jQuery

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 

</head>
<body>
    <h1>jQuery</h1>

    <div id="result"></div>

    <script type="text/javascript">
        alert(typeof jQuery);
    </script>

</body>
</html>

问题与 jQuery 位置和版本有关。它适用于

<script type="text/javascript" src="Scripts/jquery-1.11.2.min.js"></script>

但没有

<script type="text/javascript" src="Scripts/jquery-2.1.3.min.js"></script>