lundi 24 août 2020

how to use a javascript variable in django if statement

My code is

<body>
    <div class="slideshow">
      
    </div>

    <script type="text/javascript">
      function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, '\\$&');
        var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, ' '));
    }

    var section = getParameterByName('section');

    </script>
  </body>

i would like to use the variable name "section" in the if statement used in body. How can i do it?

Aucun commentaire:

Enregistrer un commentaire