locked
Hide left navigation pane in IFRAME RRS feed

  • Question

  • Hi

    i want to hide the left navigatio pane in the IFRAME, i used the following code

     

    var iFrame = crmForm.all.IFRAME_Contact;
    iFrame.src = "http://crmserver:5555/CRM/SFA/conts/edit.aspx";

    iFrame.attachEvent("onreadystatechange", Ready);
    function Ready() {
        var iDoc = iFrame.contentWindow.document;

        if (iDoc.getElementById("crmMenuBar") != null) {
            iDoc.getElementById("crmMenuBar").style.display = "none"; // hide the top menu bar
        }

        var elements2 = getElementsByClassName('ms-crm-Form-LeftBar', iDoc);
        for (var q = 0; q < elements2.length; q++) {
            elements2[q].style.display = 'none';
            elements2[q].style.width = '1%';
        }
        var tables = getElementsByClassName('ms-crm-Form-Layout',iDoc);
        for (var k = 0; k < tables.length; k++) {
            tables[k].style.tableLayout = 'auto';
        }

    }

    function getElementsByClassName(classname, doc, node) {
        if(!node) node = doc.getElementsByTagName("body")[0];
        var a = []; var re = new RegExp('\\b' + classname + '\\b');
        var els = node.getElementsByTagName("*");
        for (var i = 0, j = els.length; i < j; i++)
            if (re.test(els[i].className)) a.push(els[i]);
        return a;
    }

    every thing works fine but its showing 'Error on page' at the bottom and when i tried to close the window its raising a error 'Microsoft Dynamics CRM encountered error'

     

     

    Monday, April 12, 2010 10:18 AM

Answers

  • Firstly, you should check that the readyState of the iframe is complete or loaded before running any code in the Rrady function.

    if(iFrame.readyState == "complete" | iFrame.readyState == "loaded" ) {

        iFrame.detachEvent(......

         // Do your stuff

    }

    Also, as soon as the iframe is complete/loaded you should detach the event iFrame.detachEvent(......

     


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Monday, April 12, 2010 10:28 AM
    Moderator
  • Here is a nice post about creating the Read-Only IFRAME, hope this will give you some insights.

     

    Thanks


    Cheers, Edwin
    • Marked as answer by Jim Glass Jr Monday, April 12, 2010 3:07 PM
    Monday, April 12, 2010 11:27 AM

All replies

  • Firstly, you should check that the readyState of the iframe is complete or loaded before running any code in the Rrady function.

    if(iFrame.readyState == "complete" | iFrame.readyState == "loaded" ) {

        iFrame.detachEvent(......

         // Do your stuff

    }

    Also, as soon as the iframe is complete/loaded you should detach the event iFrame.detachEvent(......

     


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Monday, April 12, 2010 10:28 AM
    Moderator
  • Thanks RhettClinton it works

    One small question,

                How to open the record in IFrame in read-only mode.

    Monday, April 12, 2010 10:55 AM
  • Hi,

    I hope you don't want to allow customer to open records from iframe ??? then just check "Restrict cross-frame scripting" in iframe General properties.

     


    Mahain
    Monday, April 12, 2010 11:01 AM
    Moderator
  • Thanks for the reply Mahain

    when i checked the option the IFrame is showing only the tabs in Form

    Monday, April 12, 2010 11:11 AM
  • Here is a nice post about creating the Read-Only IFRAME, hope this will give you some insights.

     

    Thanks


    Cheers, Edwin
    • Marked as answer by Jim Glass Jr Monday, April 12, 2010 3:07 PM
    Monday, April 12, 2010 11:27 AM
  • If you have some type of condition that can be checked to ensure you want the form to be readonly then you could run this code when that condition is met in th form onload event

     for( var i = 0 ; i < crmForm.all.length ; i++ ) 
     { 
         if(crmForm.all[ i ].req) 
            crmForm.all[ i ].Disabled = true; 
     }
     


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Monday, April 12, 2010 11:39 AM
    Moderator