Alexey Korsakov Alexey Korsakov - 1 year ago 68
Javascript Question

Calling javascript on hosting page from MainPage

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()
HtmlPage.RegisterScriptableObject("MainPage", this);
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">
<meta charset="utf-8" />
<script type="text/javascript" src=""></script>


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

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


Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download