Clive
Clive

Reputation: 3

why will javascript not working with https

I am trying to setup a page that shows the weather from some script generated by a website, I can use this script without problems if I use http:// but it does not show up if I used https:// in Opera I see a message blocked content, any ideas what is wrong

I have tried changing the http inside the script to https but then I just see nothing


<script type='text/javascript' src='http://www.aemet.es/es/eltiempo/prediccion/municipios/launchwidget/fuente-de-piedra-id29055?w=g4p01110001ohmffffffw890z190x4f86d9t95b6e9r1s8n2'></script><noscript><a target='_blank' style='font-weight: bold;font-size: 1.20em;' href='http://www.aemet.es/es/eltiempo/prediccion/municipios/fuente-de-piedra-id29055' rel="noopener noreferrer">El Tiempo. Consulte la predicción de la AEMET para Fuente de Piedra</a></noscript>

We should see a table with 4 days weather

Upvotes: 0

Views: 476

Answers (1)

Noam
Noam

Reputation: 363

From security reasons you can't load http script in a website serverd using https.

you should replace the src="http://www.aemet.es/..." with src="https://www.aemet.es/...".

EDIT:


There is acctually additional problem.

If you open this url in your browser, you'll see that the javascript code there is adding an iframe which its url is with http, and you can't load an http resource from https website as I said.. I can't see a good solution to that.

The only solution I can see, is to copy the code there:

document.write("<iframe id=\"iframe_aemet_id29055\" name=\"iframe_aemet_id29055\" src=\"http://www.aemet.es/es/eltiempo/prediccion/municipios/mostrarwidget/fuente-de-piedra-id29055?w=g4p01110001ohmffffffw890z190x4f86d9t95b6e9r1s8n2\" width=\"890\" height=\"190\" frameborder=\"0\" scrolling=\"no\"></iframe>");

and replace the http with https:

<script>document.write("<iframe id=\"iframe_aemet_id29055\" name=\"iframe_aemet_id29055\" src=\"http://www.aemet.es/es/eltiempo/prediccion/municipios/mostrarwidget/fuente-de-piedra-id29055?w=g4p01110001ohmffffffw890z190x4f86d9t95b6e9r1s8n2\" width=\"890\" height=\"190\" frameborder=\"0\" scrolling=\"no\"></iframe>");</script>

or maybe even better, write the iframe explicity:

<iframe id="iframe_aemet_id29055" name="iframe_aemet_id29055" src="https://www.aemet.es/es/eltiempo/prediccion/municipios/mostrarwidget/fuente-de-piedra-id29055?w=g4p01110001ohmffffffw890z190x4f86d9t95b6e9r1s8n2" width="890" height="190" frameborder="0" scrolling="no"></iframe>

if you do the last option, it will also work on browsers without javascript support.

but beware! the javascript code I copied from the url might change from time to time, and then your code would remain not updated, and might not work..

I hope I helped you..

adding a snippet, pay attention that stackoverflow is https:

<iframe id="iframe_aemet_id29055" name="iframe_aemet_id29055" src="https://www.aemet.es/es/eltiempo/prediccion/municipios/mostrarwidget/fuente-de-piedra-id29055?w=g4p01110001ohmffffffw890z190x4f86d9t95b6e9r1s8n2" width="890" height="190" frameborder="0"
  scrolling="no"></iframe>

Upvotes: 1

Related Questions