0

I've got a WP site using an Aweber lightbox popup, like this:

<div class="AW-Form-627359006"></div>
<script type="text/javascript">(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "http://forms.aweber.com/form/06/627359006.js";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, "script", "aweber-wjs-zf6rn7szi"));
</script>

Everything works fine, but I'm adding some new content to the site that will all be in a specific subdirectory, and I don't want the lightbox to show for any of those pages. In other words, any page that starts with "www.mysite.com/directoryName/" should not show the lightbox. Suggestions?

Thanks!

4

1 回答 1

2

您可以使用window.location.pathname. 例子:

<div class="AW-Form-627359006"></div>
<script type="text/javascript">
    if(window.location.pathname.split('/')[1] != 'directoryName') {
        (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "http://forms.aweber.com/form/06/627359006.js";
        fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "aweber-wjs-zf6rn7szi"));
    }
</script>
于 2014-12-20T23:34:21.493 回答