Jump to content

Exclude / hide script from loading in the login page


Go to solution Solved by Nathan Explosion,

Recommended Posts

Posted
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!
Posted

We would not be able to assist with custom development under support, however I have moved your ticket to our developer connection forum for you.

Posted

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!

 

Posted

OK, I assumed by script you meant javascript code itself.

To do that, you'd probably want to put a document.write in there to handle the outputting of the html into the page.

Q: what exactly is it that you are trying to achieve? What is in the popup?

Posted

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

  • Solution
Posted (edited)

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
Posted
7 hours ago, Nathan Explosion said:

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

 

Nathan, you rock! That was above and beyond and works like a charm. Can I buy you a coffee (or a pint) or something? 

 

  • Recently Browsing   0 members

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