I have an CWE (Conversation Window Extension) for Lync. I wish to call javascript on the hosting page when my CWE gets loaded.
public MainPage()
{
try
{
HtmlPage.RegisterScriptableObject("MainPage", this);
HtmlPage.Window.Invoke("callmeonPageLoad");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "|" + ex.InnerException);
}
}
callmeonPageLoad looks like this
function callmeonPageLoad() {
if (typeof jQuery == 'undefined') {
alert("jQuery is not loaded")
} else {
alert("jQuery is loaded")
}
}
If I run this app outside Lync jQuery gets loaded. Inside app it does not. So, I cannot call any jQuery function. This is valid only if I wish to call it when page is loading (calling from MainPage).
If I implement a button in Silverlight app and make it call same javascript. jQuery is loaded already an both cases.
My question is how to call javascript which contains jquery when app is loading.
Did more investigation and found out that even such page (set as CWE) do not load 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>
Problem was related to jQuery location and version. It works with
<script type="text/javascript" src="Scripts/jquery-1.11.2.min.js"></script>
but does not
<script type="text/javascript" src="Scripts/jquery-2.1.3.min.js"></script>