Tutorial: View.attach

View.attach

Attaches a View to a window.

Example

let view;
async function createView() {
    const me = await fin.Window.getCurrent();
    return fin.View.create({ 
        name: 'viewNameAttach', 
        target: me.identity, 
        bounds: {top: 10, left: 10, width: 200, height: 200} 
    });
}

async function attachView() {
    view = await createView();
    console.log('View created.');

    await view.navigate('https://google.com');
    console.log('View navigated to given url.');

    const winOption = {
        name:'winOptionName',
        defaultWidth: 300,
        defaultHeight: 300,
        url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.create.html',
        frame: true,
        autoShow: true
    };
    const newWindow = await fin.Window.create(winOption);
    view.attach(newWindow.identity);
}

attachView()
    .then(() => console.log('View attached to new window.'))
    .catch(err => console.log(err));