What can I say, I’m sure many of you have put this to use, though here I want to publicly complain about a couple issues.
For one it would have been nice if there was some event that got clicked when one clicked a link. That could have been handled much like how my solution would show.
The other thing is support for a simple target, yep; you can put in a link but not say a target. Now how annoying is that? I don’t think the guys that developed this control even had framesets on their mind at all.
Well to my solution.
It’s rather simple when you think about it, I used the standard method of using this control, and that’s in union with a web.sitemap xml file.
I then did this to the node in question.
<siteMapNode url="BLOCKED SCRIPTOpenHome();" title="HOME" description="" >
Now all that’s cool and all notice it opens home. Well my problem and why I had to come up with this solution is that one of the pages in the application required frames. Yes I could have purchased or did my own little splitter control or something but in the end, all browsers understand framesets (was having trouble with JS in different browsers).
Plus this was only for one single part of the application which isn’t publicly exposed.
Also note I did this with master page with the sitemappath control on that page. So I then just put this little JS script on the master page and all was well.
<script language="javascript" type="text/javascript">
if (self.location.href.indexOf("PageInFrameThatUsesMasterPage.aspx")< 0)
{
if (self != top) {
top.location.href = self.location.href;
}
}
function OpenHome()
{
top.location.href = "http://www.google.com";
}
</script>
Now the script above makes it so I don’t break out of frames on the one page that I don’t want to break out. Now of course I could have just made a small function that takes a string for the URL that I put in the XML. That would have made it even smaller. This is the first draft solution that worked ok for me.
That’s it, nice and simple, though I didn’t find many answer out there on my problem. I couldn’t use my break out code on the home page since it was another site all together, hence I didn’t have control of that site. Plus don’t try onunload event, that fires on every refresh and postback.
Enjoy
Joe