0

I have some code I am trying to execute on my webpage. At first I was trying to just using JS but now I am wrapping it in JQuery as suggested here. Code is loading in page but no alert is happening...

jQuery(document).ready(function( $ ){

window.onload = function() {
alert(location.href);
if(location.href != "https://linestar.ca/contact-us/") {
      alert("Make sure you use the right contact Tab!");
} else {
    echo"LineStar Welcomes You!"
}

};


});
2
  • Your console is showing error, i also noticed that you are uinga cache plugin combining all your js file. Try to desactivate it and test again Commented Nov 10, 2017 at 18:19
  • On top of what @TemaniAfif said 1) you are including two versions of jQuery, and 2) using jQuery .ready() + window.onload is redundant - .ready() attaches to document DOMContentLoaded as well as window load events and may also fire long after both depending on when it is called.
    – ssnepenthe
    Commented Nov 10, 2017 at 18:23

1 Answer 1

3

Well don't mix PHP and Javascript without the proper tags

<script type="text/javascript">
    jQuery(document).ready(function( $ ){

        if(location.href != "https://linestar.ca/contact-us/") {
            alert("Make sure you use the right contact Tab!");
        } else {
            alert("LineStar Welcomes You!");
        }

    });
</script>

As a sidenote, your website has lots of issues that you have to work out eventually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.