Skip to main content

Microsoft Silverlight

Answered Question Accessing Script Objects from a third party websiteRSS Feed

(0)

tanlinth
tanlinth

Member

Member

32 points

40 Posts

Accessing Script Objects from a third party website

 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();
}
 

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Answered Question

Re: Accessing Script Objects from a third party website

Hi,

 I have answered same question in other post.

I think this is a duplicate post..You can close one..

Mark as answer if this post answered your question.

Harsh Bardhan

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

24939 points

2,425 Posts

Microsoft

Re: Accessing Script Objects from a third party website

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 

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities