I am aware of the <apex:page> attributes for sidebar="false" and showHeader="false" but is it possible to determine these within the page logic (either Visualforce, legitimate Javascript on page, or part of an Apex controller/action method)?

Basically, I have a Visualforce which already has some logic to determine what to show in it's main body, and in some instances, I want this to be full screen, removing the sidebar and headers, in other cases, I simply want the page to remain in the "standard" frame for the user.

Incidentally, I'm not interested in crazy Javascript hacks to target window.window.document.getElementById[..] or unsupported CSS tricks to just display:none; the relevant sections; everything I do is best practice, supported and by the book!

My current only thinking is to instead re-direct the user to a new page with those attributes set and move my "full page" experience to there. This is slightly poorer from a maintenance point of view though, and will result in double the VF pages.


You can bind these attributes to controller properties. It might get a little wonky if you try to re-render, but assuming you know the values at load time, the following binding ought to work:

<apex:page sidebar="{!showSidebar}" showHeader="{!showHeader}">
    <!-- intermediate markup -->
| improve this answer | |
  • This does work a treat, I can determine and populate the instance variables in apex in the controller extension and it drives the properties perfectly. It's so simple, it's perfect, no idea why I didn't think I could merge them in. – Simon Lawrence Feb 16 '17 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.