title: How to insert a link inside javascript (google maps)
body: <p>I want to insert a link inside inside the JavaScript.</p>
  
  <p>I want this link <code>infoWindow.setContent('&lt;a href="add-sesizare.php?lat="&gt;Adaugă sesizare pentru locația ta actuală &lt;/a&gt;.');</code> 
  to send the user to <code>add-sesizare.php?lat=&amp;lng=&amp;userid=</code></p>
  
  <pre><code>&lt;?php include 'header.php'; 
  session_start();
  
  
   if (isset($_SESSION['user'])) {
      $email = $_SESSION['user'];
      $query = "SELECT * FROM useri WHERE email='$email' LIMIT 1";
      $result = mysqli_query($con,$query);
      $user = mysqli_fetch_assoc($result);
      $userid = $user['id'];
  } else { header('Location: login.php'); }
  ?&gt;
  &lt;div class="head-first"&gt;
             &lt;div class="d-flex justify-content-between"&gt;
                      &lt;a class="navbar-brand" href="#"&gt;
                      &lt;i class="fas fa-users"&gt;&lt;/i&gt; MyCity Curtici
                      &lt;/a&gt;
                      &lt;span style="font-size:30px;cursor:pointer;padding: 0 0 0 15px;" onclick="openNav()"&gt;&amp;#9776;&lt;/span&gt;
              &lt;/div&gt; 
  &lt;/div&gt;
      &lt;div id="map"&gt;&lt;/div&gt;
      &lt;script&gt;
        // Note: This example requires that you consent to location sharing when
        // prompted by your browser. If you see the error "The Geolocation service
        // failed.", it means you probably did not give permission for the browser to
        // locate you.
        var map, infoWindow;
        var user_id = "&lt;?php echo $userid ?&gt;";
        function initMap() {
          map = new google.maps.Map(document.getElementById('map'), {
            center: {lat: 46.35, lng: 21.3},
            zoom: 15
          });
          infoWindow = new google.maps.InfoWindow;
  
          // Try HTML5 geolocation.
          if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position) {
              var pos = {
                lat: position.coords.latitude,
                lng: position.coords.longitude
              };
              infoWindow.setPosition(pos);
              infoWindow.setContent('&lt;a href="add-sesizare.php?lat="&gt;Adaugă sesizare pentru locația ta actuală &lt;/a&gt;.');
              infoWindow.open(map);
              map.setCenter(pos);
            }, function() {
              handleLocationError(true, infoWindow, map.getCenter());
            });
          } else {
            // Browser doesn't support Geolocation
            handleLocationError(false, infoWindow, map.getCenter());
          }
          google.maps.event.addListener(map, 'click', function(event) {
          window.location='add-sesizare.php?lat='+event.latLng.lat()+'&amp;long='+event.latLng.lng()+'&amp;userid='+user_id;
          });
        }
  
        function handleLocationError(browserHasGeolocation, infoWindow, pos) {
          infoWindow.setPosition(pos);
          infoWindow.setContent(browserHasGeolocation ?
                                'Error: The Geolocation service failed.' :
                                'Error: Your browser doesn\'t support geolocation.');
          infoWindow.open(map);
        }
      &lt;/script&gt;
  
      &lt;script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDd7JYEWDAJVdVkIzZOQumCHYbS2xsIvtM&amp;callback=initMap"
      async defer&gt;&lt;/script&gt;
  
  &lt;?php include 'footer.php' ?&gt;
  </code></pre>