This is a migrated thread and some comments may be shown as answers.

Get page title from page in RadPane

4 Answers 116 Views
Splitter
This is a migrated thread and some comments may be shown as answers.
paaland
Top achievements
Rank 2
paaland asked on 13 Apr 2012, 09:34 AM
I've got a site using RadSplitter with two RadPanes. One is navigation the other content. I want the browser tab title to reflect the title of the web page showing in the content pane.

I've tried something like this from a interval timer. But iframe.document.title is not the title of the web page. Any ideas?

var iframe = $find("<%= ContentPane.ClientID %>").getExtContentElement();                   
document.title = iframe.document.title;
 

4 Answers, 1 is accepted

Sort by
0
Niko
Telerik team
answered on 13 Apr 2012, 01:47 PM
Hi Pål,

In your code sample you should change the document to contentDocument since the latter is the correct property of an iframe:
var iframe = $find("<%= ContentPane.ClientID %>").getExtContentElement();                    
document.title = iframe.contentDocument.title;
 Please, note that if the content of the iframe is from another domain, the above code will violate the cross-domain constraints and it is very likely to fail.

 Another options is to try setting the title of the hosting window from the loaded content using the top reference. Therefore in the content page you could do something like this:
top.document.title = document.title;

Hope this helps.

All the best,
Niko
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
paaland
Top achievements
Rank 2
answered on 13 Apr 2012, 01:52 PM
This does not work.

iframe.contentDocument returns undefined and the call fails.

As for the other approach by letting the content page set top.document.title that would work if I had control over the content pages. Unfortunately they are "external" pages outside of my control, but luckily all on the same domain (server).
0
Accepted
Niko
Telerik team
answered on 13 Apr 2012, 02:14 PM
Hi,

From the fact that the contentDocument is undefined, I can deduct that you must be using IE7. Indeed you could get the title of the document through the contentWindow. Here is an example:
document.title = iframe.contentWindow.document.title;

Hope this helps.

Regards,
Niko
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
paaland
Top achievements
Rank 2
answered on 13 Apr 2012, 02:36 PM
Thank you. That worked. We are running IE 9, but in IE 7 compatibility mode because of compatibility issues with some of the pages running in the iframe.
Tags
Splitter
Asked by
paaland
Top achievements
Rank 2
Answers by
Niko
Telerik team
paaland
Top achievements
Rank 2
Share this question
or