I have an OOB silverlight application. I have Silverlight 5 developer runtime and all the silverlight 5 developer tools installed. The OOB Application has a silverlight view with a WebBrowser control on it. The Source that of webBrowser control is this aspx page:
<head>
<title></title>
<script type="text/javascript" language="javascript">
function test() {
if (hiddenDiv.style.display == "none")
hiddenDiv.style.display = "block";
else
hiddenDiv.style.display = "none";
}
function handCursor() {
clickTest.style.cursor = "hand";
}
function defaultCursor() {
clickTest.style.cursor = "default";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%--This Link Doesn't Work--%>
<a href="javascript: test()">Javascript Href test</a></br>
<%--This Link Works--%>
<a id="clickTest" onclick="test()" onmouseover="handCursor()" onmouseout="defaultCursor()" style="text-decoration: underline; color:Blue">OnClick Test</a>
<div id="hiddenDiv" style="display:none; background-color:Black">
<span style="color:White; display:inherit">Look at me!</span>
</div>
</div>
</form></body>
(Note: Yes I know the above code is not complete HTML. I could not get the editor to display the full page properly. I cut off the html tags. Also note that this is just a test page, not the real page I want to display in my app. I was just trying to isolate the problem).
When the above code is run in IE9 it works just fine. The links make the Div called “hiddenDiv” hide and show. When it is displayed in a WebBrowser control in a silverlight app it works fine on another developer’s machine, but on my machine it does not. I click the link and nothing happens. It appears that the javascript simply does not execute. It appears to only have this issue using the href=javascript method. onclick works great. Unfortunately I don’t own the pages i want to display in my app and cannot change the code.
A co-worker of mine believes that this issue might be due to my mistakenly installing the standard silverlight 5 runtime before realizing my mistake and installing the developer runtime. Even though I have since removed the offending file and reinstalled the Silverlight5 Tools.exe. In fact I uninstalled and re-installed all silverlight related products (except VS 2010) and uninstalled IE 9. All to no avail.
If anyone has any additional information on this problem please let me know. We need a solution that does not involve modifying the html. I dont control that html. I am hoping to embed an external web application in my OOB SL application by simply displaying it in a web browser control inside my application.
I discovered the answer to this issue on this thread:
FEATURE_SCRIPTURL_MITIGATION
The issue is a registry setting that turns elements of javascript execution on and off. It is also described in this MSDN Article: