Jump to content

Exclude / hide script from loading in the login page


Go to solution Solved by Nathan Explosion,

Recommended Posts

Hi There,
 
I added a script which is a popup inside Advanced Configuration==>Page Output==> Body code  and it shows everywhere including the login page.
 
I need to hide the popup from that page as the content of the popup is intended for members only.
 
Can you tell me how to exclude the script from loading or hide the popup from the login page.
 
Thank you for your support!
Link to comment
Share on other sites

Thanks Nathan!

I did try your code but it did not work as I get a syntax error when inspecting through Chrome console

This the error I see: Uncaught SyntaxError: Unexpected token '<' (at (index):1840:4)

I don't think a I can put a script within a script, I think that is what causing the error.

The popup script is the following: <div class="popup" id="51f18_16504"></div><script src="https://www.powr.io/powr.js?platform=html"></script>

This is how I put it inside the code you provided:

<script>
    $(document).ready(function(){
        var page = $('body').attr("data-pageController");
        if (page != 'login'){
            <div class="popup" id="51f18_16504"></
div><script src="https://www.powr.io/powr.js?platform=html"></script>
        }    
    });
</script>

Any idea how I can insert the popup scriot correctly without causing that error?

Thank you very much!

 

Link to comment
Share on other sites

The popup is just to remind my members with our Q&A call. ( screenshot attached).

The poup has text, image and a countdown timer.

As you can see from the screenshot attached, I can't have the popup show up in the login page as it contain a link to where members can join the Q&A that is why I want to hide from the login page.

How do I put a document.write inside the code you provided?

Thanks again for your help, much appreciated.

Could contain: Text, File, Page

Link to comment
Share on other sites

  • Solution

Give this a try - plugin instead of trying to write some javascript.

It will insert this:

  <div class="popup" id="51f18_16504"></div>
<script src="https://www.powr.io/powr.js?platform=html">

...on every front-end page of your site, apart from the /login page.

(NE) Exclude _ hide script from loading in the login page 1.0.0.xml

Off to the pub now, back tomorrow.

Edited by Nathan Explosion
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...