2015-12-22 89 views

回答

1

如果您试图破解nlobjform的NetSuite样式表,这可能不是理想的,因为NetSuite可以随时更改该样式表,因为它可能取决于NetSuite的默认DOM。

如果您想要自己的完整样式,您可以在嵌入式HTML中嵌入iframe,然后使用自己的样式表完全设置页面样式。

如果您不希望NetSuite标题和菜单选项也出现,那么我建议您在response对象中返回完整的HTML和样式表标签。

response.setContentType('HTMLDOC'); 
response.write(HTML_AS_STRING); 
+0

我可以用我自己的形式吗?而不是在上面的例子中使用netsuite。你能举个例子吗? –

+0

'response.setContentType('HTMLDOC'); response.write(HTML_AS_STRING);'使用您的表单HTML字符串值作为'HTML_AS_STRING' – prasun

3

正如prasun指出的那样,您可以从Suitelet返回想要的任何原始HTML,包括您自己的完整CSS。我们通常会将HTML和CSS文件放在文件柜中,并在需要动态信息的位置放置特殊标签来处理此问题。 Suitelet然后简单地加载这些文件,相应地替换标签,并返回完整的HTML。简单的例子可能是这个样子:

文件柜/ SuiteScripts /我的项目/ myHtml.html:

<!DOCTYPE html> 
<html> 
    <head> 
     <title>My Suitelet Report</title> 
     <!-- This tag will be replaced with the CSS file; unfortunately, NetSuite does 
      not apply the styles if they are included with a link tag --> 
     <style>NL_CSS</style> 
    </head> 
    <body> 
     <p id="data-desc"><span id="data-month">NL_MONTH</span> <span id="data-year">NL_YEAR</span></p> 
    </body> 
</html> 

文件柜/ SuiteScripts /我的项目/ myStyles.css:

body { 
    font-size: 1em; 
    font-family: "Lucida Grande", Verdana, Arial, sans-serif; 
    margin: 1em 1.5em; 
} 

p#data-desc { 
    font-size: 0.85em; 
    font-weight: bold; 
    margin: 1em 0; 
} 

文件柜/ SuiteScripts /我的项目/ mySuitelet.js:

function onRequest(request, response) { 
    // Load the HTML content 
    var html = nlapiLoadFile('SuiteScripts/my-project/myHtml.html').getValue(); 

    // Current date 
    var now = moment(); 

    // Replace the month and year tags with real values 
    html = html.replace(/NL_MONTH/, moment.months()[now.month()]); 
    html = html.replace(/NL_YEAR/, now.year()); 

    // Load the CSS file to obtain its URL 
    file = nlapiLoadFile('SuiteScripts/my-project/myStyles.css'); 

    // Replace the NL tag with the CSS contents 
    html = html.replace(/NL_CSS/, file.getValue()); 

    response.write(html); 
} 
相关问题