# Can't open pop up or new tab and display generate html

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-open-pop-up-or-new-tab-and-display-generate-html%2F102095%3E%5C
**Category:** Spaces\
**Created:** [August 13, 2024, 3:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-open-pop-up-or-new-tab-and-display-generate-html%2F102095 "2024-08-13T03:35:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheDrakosfire](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@TheDrakosfire](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FTheDrakosfire)%5C
**Post date:** [August 13, 2024, 3:35am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcant-open-pop-up-or-new-tab-and-display-generate-html%2F102095%2F1 "2024-08-13T03:35:47Z")

</div>

Code and example running here [https://huggingface.co/spaces/TheDrakosfire/StoreGenerator](https://huggingface.co/spaces/TheDrakosfire/StoreGenerator)

I’ve got a container running flask hosting an html file, scripts, css.  
Locally, when I click my button to open a new tab with specific isolated html from the main page, it works perfectly. This also works for a pop up that goes straight to printing as pdf, or creating a pdf to download.

Once deployed to Spaces, this creates blank pages. This seems like a security response to prevent pop ups.

ASK: Is this a security measure? Is there a way to grant permissions?  
ASK: Is there another way to accomplish this goal?

```auto

    window.printPageContainer = function() {
        var pageContainer = document.getElementById('brewRenderer');
            
            htmlContent = `
                <!DOCTYPE html>
                <html lang="en">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <link href="./dependencies/all.css" rel="stylesheet">
                    <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css">
                    <link href="./dependencies/bundle.css" rel="stylesheet">
                    <link href="./dependencies/style.css" rel="stylesheet">
                    <link href="./dependencies/5ePHBstyle.css" rel="stylesheet">
                    <link href="./storeUI.css" rel="stylesheet">  
                    <title>Print Preview - DnD Stat Block</title>
                    <link rel="stylesheet" href="styles.css">
                    <style>
                        @media print {
                            
                            .page {
                                page-break-before: auto;
                                page-break-after: avoid;
                                page-break-inside: avoid;
                                
                            }
                            .columnWrapper {
                                overflow: visible;
                            }
                            
                        }
                    </style>
                </head>
                <body>
                    ${pageContainer.innerHTML}
                </body>
                </html>
            `;
            // Open a new tab
        const newTab = window.open('', '_blank');

        // Check if the new tab was blocked
        if (newTab) {
            // Write the HTML content to the new tab
            newTab.document.open();
            newTab.document.write(htmlContent);
            newTab.document.close();
        } else {
            console.error('Failed to open a new tab. It may have been blocked by the browser.');
        }
    };

```
