Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run script if on certain webpage

I have a script that loads a music player but I only want to run it on my podcasts page.

It should go something like if window.location is example.com/podcasts then <script> blah </script>

How can I do this? Thanks!

like image 639
zmanw Avatar asked Jan 17 '23 05:01

zmanw


1 Answers

The javascript would be:

<script type="text/javascript">
    if(window.location.pathname == '/podcast') {
        // script body here
    }
</script>
like image 187
kingcoyote Avatar answered Jan 24 '23 21:01

kingcoyote