0

I am attaching client script to Nestuite iframe suitelet to hide div element.

Here's the strange part: 1.If I inspect the element in the browser's developer tools and then execute document.getElementById('abc') in the console, it returns null. 2. But, if I copy the JSON path of the element in the developer tools and then execute document.getElementById('abc') in the console, it correctly returns the element.

Below in Netsuite client script:

//Client Script
function pageInit(scriptContext) {
    document.getElementById("uif37");
}

//i_frame suitelet
 if (context.request.method === 'GET') {

            var form = serverWidget.createForm({title: 'Monitoring System', hideNavBar: true});
           
            // Construct URLs for child Suitelets
            var fisrtiframeUrl = buildIframeUrl('scriptid', 'deployid');
            var secondiframeUrl = buildIframeUrl('scriptid', 'deployid);
          

            var fisrtiFrameHtml = "<iframe src='" + fisrtiframeUrl + "' id='view' width='50%' height='700px' scrolling='auto'  name='firstframeView' marginheight='0' marginwidth='0' frameborder='0'></iframe>";
            var secondiFrameHtml = "<iframe src='" + secondiframeUrl + "' id='view' width='50%' height='700px' scrolling='auto' name='secondframeView' marginheight='0' marginwidth='0' frameborder='0'></iframe>";
        

            var combinedHtml = fisrtiFrameHtml + secondiFrameHtml;

            var htmlField = form.addField({
                id: 'custpage_my_iframe',
                type: serverWidget.FieldType.INLINEHTML,
                label: 'Performance  iFrame'
            });
            htmlField.defaultValue = combinedHtml;
            form.clientScriptModulePath = 'SuiteScripts/cs_hide_div.js';


            form.addResetButton({label: 'Cancel'});

            context.response.writePage(form);
        }
    }
4
  • 4
    Just copying the value changes the behavior? You're not talking about pasting/using it somewhere else? Don't see how that would make any difference - unless perhaps there's (i)frames involved, and by inspecting the element to copy that value, you are somehow changing the console context window? Commented Mar 7 at 12:28
  • I am just copying the JSON path not pasting anywhere. and then putting document.getElementById('uif37') in console and it works. yes I am using iframe suitelet. Commented Mar 7 at 12:30
  • 4
    The .getElementById() function will only find the element if it is actually part of the page when your script runs. Commented Mar 7 at 12:37
  • It worked with document.getElementById('myframe1').contentWindow.document.getElementById('x') now, the issue is, when main suitelet intially loading, it shows elemnets to be hidden. it hides elements only after page completely reloaded. Commented Mar 7 at 16:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.