2015-12-22 91 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); 
} 
相關問題