Get page title from page in RadPane

5 posts, 1 answers
  1. paaland
    paaland avatar
    17 posts
    Member since:
    Jun 2009

    Posted 13 Apr 2012 Link to this post

    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;
     
  2. Niko
    Admin
    Niko avatar
    387 posts

    Posted 13 Apr 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. paaland
    paaland avatar
    17 posts
    Member since:
    Jun 2009

    Posted 13 Apr 2012 Link to this post

    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).
  5. Answer
    Niko
    Admin
    Niko avatar
    387 posts

    Posted 13 Apr 2012 Link to this post

    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.
  6. paaland
    paaland avatar
    17 posts
    Member since:
    Jun 2009

    Posted 13 Apr 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017