Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
trying to change iframe location from javascript

i have many stores every store got latitude, longitude when i click location icon for any store i send latitude, longitude to javascript function and change iframe src in js function and i show model showing the iframe but the iframe not showing the location here is the code.

iframe error www.google.com refused to connect.

icon button <a onclick="getLocation({{$store->lat}},{{$store->lon}})" data-toggle="modal" href="#edit_location"><i style="font-size: 25px; color: #009688;" class="fas fa-location-arrow"></i></a>

iframe in model

<div class="mapouter mt-3"><div class="gmap_canvas"><iframe  id="gmap_canvas" src="" frameborder="0" scrolling="no" style="width: 100%; height: 400px;"></iframe><a href="https://fnftest.net" style="display:none">fnf test playground remake</a><style>.mapouter{position:relative;text-align:right;height:400px;width:100%;}</style><a href="https://www.googlemapsiframegenerator.com" style="display:none">Google Maps Iframe Generator - Free Html Embed Code</a><style>.gmap_canvas{overflow:hidden;background:none!important;height:400px;width:100%;}</style></div></div>

javascript function

function getLocation(lat,lon){
    var loc = document.getElementById('gmap_canvas');
    loc.src = 'https://maps.google.com/maps?q=' + lat + ',' + lon + '&hl=es;z=14&amp;output=embed';
}

Note when i give iframe src any static location without js it works the problem when i change the src from js the error show

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Where is your JS function located - I am assuming it is in an external script resource, and not directly contained inside the HTML document?

loc.src = 'https://maps.google.com/maps?q=' + lat + ',' + lon + '&hl=es;z=14&amp;output=embed';

Replace the &amp; with a single & then. Encoding this as &amp; would only be necessary, if the context was HTML - but that is not the case, if this code resides in an external JS resource.

Google does give me the "connection refused" message when I try to use this URL with &amp; (more precise, the browser said it has X-Frame-Options set to Deny), but it appears to work fine with just &.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda