Simulate SiteMap item click from Ribbon JavaScript RRS feed

  • Question

  • Hi all,

    I want to be able to simulate clicking on a Site Map element to display the HTML web resource that it's linked to.

    I have called document.getElementById("blah").click() on the <li> element and the <a> element within it, and both error out with no support for that function.

    What this would achieve is displaying a HTML web resource within the main page (like when you link the SiteMap to a URL), so opening a new window or dialog isn't really an option

    Has anyone done this before, or know if I'm barking up the wrong tree?

    Thursday, September 5, 2013 10:37 AM

All replies

  • You might like to think about loading your web resource in its own window from the ribbon as the Sitemap link will probably not exist in the same form (DOM or scope) if you upgrade to 2013.

    MS CRM Bing'd - http://bingsoft.wordpress.com
    Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM 2011 Metadata Browser
    CRM Forum Guidance

    Thursday, September 5, 2013 3:21 PM
  • Where do you intend to place the code that is simulating the click?
    Thursday, September 5, 2013 3:45 PM
  • The code is currently running in the application ribbon for testing purposes, with the idea that it gets rolled out to all Homepage Ribbons.

    The HTML resource to be called is a configuration/landing page which doesn't suit being displayed in a modal dialog or separate window.

    Changing the 'content frame' IFrame source to a web resource must be possible, as this is OOB behaviour for SiteMap elements, however there doesn't seem to be any way (supported or otherwise) to modify this through JavaScript

    • Edited by KittenFace52 Thursday, September 5, 2013 3:55 PM
    Thursday, September 5, 2013 3:55 PM
  • document.getElementById("contentIFrame").src= <webresource path>
    Highly unsupported though!

    Thursday, September 5, 2013 4:05 PM
  • I should have mentioned that I tried this before trying to simulate the SiteMap click, as there is an error produced saying that contentIFrame doesn't have a src property!
    Thursday, September 5, 2013 4:12 PM
  • Running the same script in the browser console works on IE as well as Chrome.

    Syntax error maybe?

    Thursday, September 5, 2013 4:22 PM