var win $(function () { Root = $('#Root').val();//Set the root directory }); function OpenPlayer(id, type, add) { //This is used to limit the same window to only It can pop up once //In fact, even if there is no restriction, as long as the name in the window.open parameter is the same, it will not be opened repeatedly //You can refer to other articles for the parameters in window.open, there are many if (win == null || win.closed) { win = window.open('http://loaclhost/sl.aspx', 'win', 'width=870,height=650,top =1,left=0,scrollbars=0,resizable=0,status=1', true); }
As we all know, the first line is A prompt box pops up in this window (this can be generally omitted~) In fact, this and win point to the same type but different objects So, their methods are the same. The second line is the code to pop up a prompt box in the sub-window. You can also write events of the subform in the parent form~ The function of the third line is that when the subform is loaded, the parent window pops up a prompt box. 2. The child form calls the parent form This is similar to the above. When the parent form opens a child form, you can access the parent form window like this. opener This object is the parent form, just call the corresponding function directly 3. The subform calls the silverlight function or object This is introduced in detail on MSND, in Chinese ~ Here, I will help you mention the main steps (the method of calling the silverlight object will not be posted, it is included in it) Attached is the portal: 1. Now in silverlight, the method that needs to be called is The called function adds an attribute - ScriptableMember
MyScriptableManagedType smt = new MyScriptableManagedType() ; HtmlPage.RegisterScriptableObject("mySLapp", smt); //If this function is not a function in the external class, but a function of the sl body, then just pass in the this pointer directly
3. Open the page where slverlight is located In the Silverlight object tag, add the onLoad attribute with the value "pluginLoaded". The following example demonstrates the HTML markup used for Silverlight control references.
4. In the existing script element on the page, add the JavaScript function of the pluginLoaded method. Use the getHost method to obtain a reference to the Silverlight control. The following example shows the JavaScript code for the pluginLoaded method.
4. Silverlight calls js in the subform Similarly, it is also an article on MSDN~ Portal: This is super simple and direct: HtmlPage.Window.Invoke ("MethodName", args); The first parameter is the function name, and the following parameter is the parameter that needs to be passed in for this function. Improvement 5. When the parent page opens the child page, Directly pass in parameters to silverlight This is mainly used during initialization In the first part, we opened the http://loaclhost/sl.aspx sub-window This At this time, we can use GET to pass in some parameters such as: http://loaclhost/sl.aspx?id=1 and then access it in silverlight like this:
string id = HtmlPage.Document.QueryString ["id"];
6. How to bring the child window to the front? The silverlight application in my subpage is actually a music player, so the subpage is generally minimized. However, when I pop up the MessageBox in the silverlight application, it is still in a minimized state... This is very unfriendly to users. If you want to bring the child window to the front, you can only call the win.focus() function in the parent window. However, as long as we do a little processing, it can be achieved in the parent window, child window, and sl. This purpose is so you can do this: 1. Write a function in the parent window, called Focus() Then call win.focus(); 2. Write a function in the child window function, called Focus() Call window.opener.Focus() 3. Finally, if you want the silverlight application to be brought to the front, you can call the Focus() function in the parent window or child window, or you can Then call the Focus() function of the sub-window in silverlight
7. How to judge that silverlight has been loaded? There are several ideas below, some are right and some are wrong (√) In the constructor of the silverlight application, call the js of the subpage or parent page (through the subpage) [This method is feasible, but Slightly troublesome] (×) Write the window.onload event in the sub-page [silverlight may not be loaded when this event is triggered] (√) Remember the third part, step 3? ? [Recommended practice] After adding this, the function that triggers the subpage will be triggered after silverlight is loaded. The function name can be changed.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn