0

I am writing a Google Apps Script to be embedded into Google Sites to retrieve the names and URLs for child pages of the current page. When I call the getURL() function I am getting the following error:

'TypeError: Cannot find function getURL in object WebPage.'

My code is as follows:

function doGet() {

    var app = UiApp.createApplication();

    var pages = SitesApp.getActivePage().getChildren();

    for (var i = 0; i < pages.length; i++) {
        Logger.log(pages[i].getURL());
    }

    return app;
}

I am new to Google Apps Scripts so am struggling to work out what this means. Any help would be greatly appreciated.

1 Answer 1

2

Use pages[i].getUrl()

You should use the autocomplete feature in the script editor to avoid such typing errors (control space after the dot : page[i].here type CTRL space and you'll see all possible methods...)

Note : the general rule in javascript is to use the so called camelCase format : getRange, createLabel ... there are only a few exceptions like setHTML but every rule must have exceptions doesn't it ?

Sign up to request clarification or add additional context in comments.

1 Comment

the simplest errors are the one we make most easily... That's why we invented technology ;-) thank you Google !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.