1

In a iframe I set the src to a page containing Silverlight Web Part, it doesn't generate any anchor element, but on the silverlight web part there are text we can click on and they will redirect the page to a new url.

The problem is the url always opens in the iframe instead of the parent window. I tried the following things:

<base target="_search" />
<base target="_top" />
<base target="_parent" />

inside the <head></head> of my iframe page and without the "" and the / but none worked.

The Silverlight is a Sharepoint component so I could not change it or see the code to know how it open links, so I could do nothing about that.

I'd like very much to know if there are any other violent ways to force links to open in the parent window? Thanks for your help.

wceo
  • 934
  • 3
  • 18
  • 40
  • 1
    You can try to reload the main page by javascript each time the content of the iframe element is changed, if this method works: http://stackoverflow.com/questions/2429045/iframe-src-change-event-detection – vortexwolf Dec 26 '12 at 19:14
  • @vorrtex Thank you, this solution has inspired me to a not very clean solution. After `onload` event I set the url of `top.window.location.href` to the iframe's `this.contentWindow.location`. However, the page is already loaded when I change the loacation of the top window, so it's not very good for users. You've got an idea how to get the redirect url before the `onload`? Thanks! – wceo Dec 27 '12 at 10:27
  • It would be possible if you had access to the code of the Silverlight Web Part. You could handle the click event and call javascript code instead. If you don't have access, you can make some kind of reverse engineering and recompile that webpart. That's the only one way. – vortexwolf Dec 27 '12 at 11:17
  • @vorrtex Unfortunately I've no access to the Silverlight Web Part. It's a Sharepoint build-in Web Part... I don't understand very well " reverse engineering and recompile", would you please explain that to me? Thanks :) – wceo Dec 27 '12 at 11:26
  • Find the link to the necessary *.xap file in the source code of the page, download and unpack it (it is just a zip-archive). Then you can use some kind of .Net Reflector in order to get the source code and xap files. Create your own silverlight project by using these files, implement a custom web part and use it instead of the built-in web part. Not so easy, but it will certainly work. – vortexwolf Dec 27 '12 at 13:59
  • @vorrtex I tried decompiling the .dll and found what to change. However it seems impossible to recompile it or to change the dll, and the project is too complicated to reproduce... Seems that I have to give it up, sorry :( – wceo Jan 11 '13 at 11:41

1 Answers1

2

If this is the same issue I've been working on(adding the organization browser in sharepoint inside of an iFrame) today this may help. On the page that contains the silverlight web part and is viewed through an iFrame on a different page, I override the window.open function that is used by silverlight to change the url. Below I change the URL of the parent window so the subsequent navigation takes place in the main window and the iframe is completely transparent to the user.

This may be useful to you, haven't tried, but I'm assuming you'll be able to find your other iframes once you get to the top frame. This is also cross domain in my case.

<script>
//Window.open override - catches HTMLWindow.Navigate from silverlight hyperlink
window.open = function (open) {
    return function (url, name, features) {
        window.top.location = url;
        return false;
   };
}(window.open);
</script>
david
  • 36
  • 1
  • Thanks!!!! The organization browser is exactly the thing that I'm working on!!! I didn't know HTMLWindow.Navigat uses window.open. Thank you very much again!! – wceo Jan 16 '13 at 08:56