简体   繁体   中英

Hide external element on page load

I am using the Incapsuala Web Application Firewall. It allows me to display the Incapsula seal on the bottom left of my pages. However, I have a few pop up pages that I need to generate for some PDF report - the pop up pages are showing the seal and as a result are also displaying on the generated PDF documents.

I think the following is the Incapsula code

<script type="text/javascript">
//<![CDATA[
(function() {
var _analytics_scr = document.createElement('script');
_analytics_scr.type = 'text/javascript'; _analytics_scr.async = true; _analytics_scr.src = '/_Incapsula_Resource?SWJIYLWA=9e14fec597ae623cd2f9cd71c4403630&ns=36';
var _analytics_elem = document.getElementsByTagName('script')[0]; _analytics_elem.parentNode.insertBefore(_analytics_scr, _analytics_elem);
})();
// ]]>
</script>

How can I hide this when the pop up page is generated?

Not sure but maybe this will help, but you can use Phontom.js Use page.onResourceRequested method to abort all requests to google analytics.

You can read up on it here

page.onResourceRequested = function(requestData, request) {
    if ((/google-analytics\.com/gi).test(requestData['url'])){
        console.log('Request to GA. Aborting: ' + requestData['url']);
        request.abort();
    }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM