• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to check current page type

Community Expert ,
Nov 30, 2017 Nov 30, 2017

Copy link to clipboard

Copied

"Welcome back my friends to the show that never ends" - I'm trying to handle variables and need to know whether the  current page is a master page or body page. As You know, on a master page more system variables are valid (Running H/F xx, Current Page #). So to set up a list of valid system vars I need to know where I am.

I read in the doc: PageObject is any Page object i.e., BodyPage, MasterPage, ReferencePage, HiddenPage.

Experiments show that I get answers with this short pgm - but what kind of pages are 'hidden' in the values 0...4, > 7 ?

Is this the correct way to test for the page type?

// CheckPageType.jsx
var   oDoc = app.ActiveDoc;
var   oPage = oDoc.CurrentPage;
var pageType = oPage.type;
$.writeln ("page = " + pageType);
/* type reported
   5   Constants.FO_BodyPage     
   6   Constants.FO_MasterPage
   7   Constants.FO_RefPage
*/

Ah well, "don't check for an error situation you don't know how to handle".

Klaus

TOPICS
Scripting

Views

385

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 30, 2017 Nov 30, 2017

Another way to check is like this:

#target framemaker

var doc = app.ActiveDoc;

var page = doc.CurrentPage;

alert (page.constructor.name);

This will return one of these strings: BodyPage, MasterPage, RefPage

Votes

Translate

Translate
Enthusiast ,
Nov 30, 2017 Nov 30, 2017

Copy link to clipboard

Copied

Klaus,

I don't think that the oDoc.CurrentPage can ever be a HiddenPage because you can't interact with them directly.

When I work with the various page types I normally get the page's Object type using instanceof, it seems to be more reliable. I use it like this:

var   oDoc = app.ActiveDoc; 

var   oPage = oDoc.CurrentPage; 

var pageType = oPage.type; 

if (oPage instanceof BodyPage) {

    $.writeln ("This is a Body Page");

    }

I hope that helps?

Ian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2017 Nov 30, 2017

Copy link to clipboard

Copied

LATEST

Another way to check is like this:

#target framemaker

var doc = app.ActiveDoc;

var page = doc.CurrentPage;

alert (page.constructor.name);

This will return one of these strings: BodyPage, MasterPage, RefPage

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines