Home > Web Front-end > JS Tutorial > Chrome extension development: How open popup.html to the right and top of the page

Chrome extension development: How open popup.html to the right and top of the page

PHPz
Release: 2024-09-11 06:34:36
Original
734 people have browsed it

Chrome extension development: How open popup.html to the right and top of the page

Buy default the popup opened below the extension icon, we can change the position by create a new window

chrome.action.onClicked.addListener(async (tab) => {
    openPopup(tab)
});

const openPopup = async (tab) => {
    const currentWindow = await chrome.windows.getCurrent();
    let window = await chrome.windows.create({
        url: './popup.html',
        type: 'popup',
        width: 320,
        height: 578,
        left: currentWindow.left + currentWindow.width - 320,
        top: 100
    });
    chrome.windows.update(window.id, { focused: true });
}
Copy after login

The above is the detailed content of Chrome extension development: How open popup.html to the right and top of the page. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template