Skip to main content
Home Forums Silverlight Programming Programming with JavaScript Accessing Script Objects from a third party website
2 replies. Latest Post by Jonathan Shen – MSFT on September 2, 2008.
(0)
tanlinth
Member
32 points
40 Posts
08-29-2008 9:05 AM |
Hi,
I have to web hosts. One is an apache server (localhost) and the other is the VS 2008 debugging server (the one we get when running a web project).I currently have a php webpage on the apache server, which contains the silverlight object hosted on the VS 2008 server, I also have a accompanying JavaScript file which allows me to access the HTML elements on the php web page. I have an object('bar') declared as a ScriptableObject in the Silverlight 2 application.
When I click on the php webpage, the Javascript will find the closest element to where I clicked and will give the X Y coordinates of the element. However it seems that I can't access the Scriptable object. I have made the enableHtmlAccess property to true in the Silverlight object. Please help. Any help is much appreciated. :)
Thank you.
Nilu
My code is below:
Silverlight Code:
[ScriptableType]public partial class Page : UserControl{ void Page_Loaded(object sender, RoutedEventArgs e) { XYPos myObject = new XYPos(); // contains ScriptableMembers X and Y HtmlPage.RegisterScriptableObject("myObject", myObject); }... private void getPos(double x, double y) { HtmlPage.Window.Invoke("getPos", x, y); }}
JavaScript Code:
function getPos(x, y) { // get the silverlight object var silverlightObj = document.getElementById('silverlightObject'); silverlightObj.content.myObject.X = getClosestElementX(); silverlightObj.content.myObject.Y = getClosestElementY();}
HarshBar...
Star
9908 points
1,719 Posts
08-29-2008 9:40 AM |
I have answered same question in other post.
I think this is a duplicate post..You can close one..
Jonathan...
All-Star
24939 points
2,425 Posts
09-02-2008 4:19 AM |
Hi all,
For the convenience to our community members, we find the url and paste it here. By the way, please don't post duplicate thread in this forum. Thanks.
Best regards,
Jonathan