简体   繁体   English

如何将标题HTML添加到VF页面

[英]How to add header html to VF page

<apex:page showheader="false" sidebar="false">
</head>
<body>
<div>
Header html should load here 
</div>
</body>
</html>
</apex:page>

I have a html file with some heading html codes. 我有一个带有一些标题html代码的html文件。 'header.html' how to include this file to my VF page as dynamic header? 'header.html'如何将此文件作为动态标题包含到我的VF页面中?

Salesforce store your HTML file inside the database as metadata, so this means that it can be queried for. Salesforce将HTML文件作为元数据存储在数据库中,因此这意味着可以对其进行查询。

You'll need a controller extension for your <apex:page> . 您需要为<apex:page>扩展控制器。 Check this link on how to do that. 检查此链接以了解有关操作方法。

So, your controller will have a method like so: 因此,您的控制器将具有如下方法:

public string getHeaderHtml() {
        try {
            return [Select Body From Document Where Id = 'YOUR_PAGE_ID'].Body.toString();

        } catch(exception e) {
            return '';
        }
    }

And in your Visualforce page you'll have this line where you want your HeaderHtml to be placed: 在Visualforce页面中,您将有以下行希望放置HeaderHtml:

<apex:outputText escape="false" value="{!HeaderHtml}"/>

OR 要么

Alternative option is to use <apex:iframe> with it's src pointing to your header file url like src="/apex/MyPage" . 另一种选择是使用<apex:iframe> ,它的src指向您的头文件url,如src="/apex/MyPage" Check the documentation link . 检查文档链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在HTML可打印版本中添加页眉和页脚以及页数? - How to add header and footer and number of page to html printable version? 如何通过 CSS 向 HTML 页面添加标题? - How could I add a header to a HTML page via CSS? 将 wordpress header 和页脚添加到 HTML 页面 - Add wordpress header and footer to HTML page 通过css将标题添加到HTML页面中进行打印 - add header to html page in printing by css 将 HTML 页面添加到 Wordpress 保留 header 和页脚 - Add HTML page to Wordpress keeping header and footer 如何使用 Node js、ExpressJS、hbs 或 ejs 在多页网站的 html 页面中添加通用页眉和页脚 - How add common header and footer in html page for multi page website using Node js, ExpressJS,hbs or ejs 在 HTML 中打印时,如何在每个页面中为动态内容添加固定的页眉和页脚? - How do I add fixed header and footer for dynamic content in each page while printing in HTML? 如何在另一个HTML页面中包含一个HTML页面(作为标题)? - How to include one html page(as header) in another html page? 如何在HTML中将div作为页面标题打印 - How to print a div as page header in html 如何为HTML页面设置字符集标题? - How to set a charset header for a html page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM