Insert HTML Content from URL into HTML (form, div, iframe, …)











up vote
0
down vote

favorite












I want to display the result of this URL



http://api.openweathermap.org/data/2.5/weather?q=Berlin,de&mode=html&appid=...1



which looks like



https://i.stack.imgur.com/WWRoD.png


how can I insert the HTML content from the URL directly into an iframe or div?
Thanks!










share|improve this question






















  • Will the content be an image?
    – Christheoreo
    Nov 22 at 16:20















up vote
0
down vote

favorite












I want to display the result of this URL



http://api.openweathermap.org/data/2.5/weather?q=Berlin,de&mode=html&appid=...1



which looks like



https://i.stack.imgur.com/WWRoD.png


how can I insert the HTML content from the URL directly into an iframe or div?
Thanks!










share|improve this question






















  • Will the content be an image?
    – Christheoreo
    Nov 22 at 16:20













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I want to display the result of this URL



http://api.openweathermap.org/data/2.5/weather?q=Berlin,de&mode=html&appid=...1



which looks like



https://i.stack.imgur.com/WWRoD.png


how can I insert the HTML content from the URL directly into an iframe or div?
Thanks!










share|improve this question













I want to display the result of this URL



http://api.openweathermap.org/data/2.5/weather?q=Berlin,de&mode=html&appid=...1



which looks like



https://i.stack.imgur.com/WWRoD.png


how can I insert the HTML content from the URL directly into an iframe or div?
Thanks!







javascript html css iframe






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 16:15









Mawima

11




11












  • Will the content be an image?
    – Christheoreo
    Nov 22 at 16:20


















  • Will the content be an image?
    – Christheoreo
    Nov 22 at 16:20
















Will the content be an image?
– Christheoreo
Nov 22 at 16:20




Will the content be an image?
– Christheoreo
Nov 22 at 16:20












2 Answers
2






active

oldest

votes

















up vote
1
down vote













If you already are able to get that response html, all you need to do is insert it onto the page



document.getElementById('mydiv').innerHTML = "<p>some html</p>"





share|improve this answer





















  • No, I have the link or API URL and I want to get the content in form of html back..
    – Mawima
    Nov 22 at 17:00










  • Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
    – SpeedOfRound
    Nov 22 at 18:03


















up vote
0
down vote













This could easily be achieved by PHP.



<?php
echo file_get_contents("ENTER URL HERE");
?>


You could do this via JavaScript, but that would require making an AJAX request to get the HTML and then inserting it into the DOM. I don't think that this would be the best method as the page would have already loaded without the code and then asynchronously adding it to the page. Depending on how it is meant to be viewed, I think this would lead to a poorer UX.



Edit



To download the HTML asynchronously, you should use .get(), instead of .load().



$.get("URL", function(data) {
$(".mydiv").html(data);
});





share|improve this answer























  • I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
    – Mawima
    Nov 22 at 20:17













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434842%2finsert-html-content-from-url-into-html-form-div-iframe%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













If you already are able to get that response html, all you need to do is insert it onto the page



document.getElementById('mydiv').innerHTML = "<p>some html</p>"





share|improve this answer





















  • No, I have the link or API URL and I want to get the content in form of html back..
    – Mawima
    Nov 22 at 17:00










  • Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
    – SpeedOfRound
    Nov 22 at 18:03















up vote
1
down vote













If you already are able to get that response html, all you need to do is insert it onto the page



document.getElementById('mydiv').innerHTML = "<p>some html</p>"





share|improve this answer





















  • No, I have the link or API URL and I want to get the content in form of html back..
    – Mawima
    Nov 22 at 17:00










  • Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
    – SpeedOfRound
    Nov 22 at 18:03













up vote
1
down vote










up vote
1
down vote









If you already are able to get that response html, all you need to do is insert it onto the page



document.getElementById('mydiv').innerHTML = "<p>some html</p>"





share|improve this answer












If you already are able to get that response html, all you need to do is insert it onto the page



document.getElementById('mydiv').innerHTML = "<p>some html</p>"






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 16:22









SpeedOfRound

603314




603314












  • No, I have the link or API URL and I want to get the content in form of html back..
    – Mawima
    Nov 22 at 17:00










  • Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
    – SpeedOfRound
    Nov 22 at 18:03


















  • No, I have the link or API URL and I want to get the content in form of html back..
    – Mawima
    Nov 22 at 17:00










  • Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
    – SpeedOfRound
    Nov 22 at 18:03
















No, I have the link or API URL and I want to get the content in form of html back..
– Mawima
Nov 22 at 17:00




No, I have the link or API URL and I want to get the content in form of html back..
– Mawima
Nov 22 at 17:00












Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
– SpeedOfRound
Nov 22 at 18:03




Why are you not just their embedded widgets? openweathermap.org/widgets-constructor
– SpeedOfRound
Nov 22 at 18:03












up vote
0
down vote













This could easily be achieved by PHP.



<?php
echo file_get_contents("ENTER URL HERE");
?>


You could do this via JavaScript, but that would require making an AJAX request to get the HTML and then inserting it into the DOM. I don't think that this would be the best method as the page would have already loaded without the code and then asynchronously adding it to the page. Depending on how it is meant to be viewed, I think this would lead to a poorer UX.



Edit



To download the HTML asynchronously, you should use .get(), instead of .load().



$.get("URL", function(data) {
$(".mydiv").html(data);
});





share|improve this answer























  • I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
    – Mawima
    Nov 22 at 20:17

















up vote
0
down vote













This could easily be achieved by PHP.



<?php
echo file_get_contents("ENTER URL HERE");
?>


You could do this via JavaScript, but that would require making an AJAX request to get the HTML and then inserting it into the DOM. I don't think that this would be the best method as the page would have already loaded without the code and then asynchronously adding it to the page. Depending on how it is meant to be viewed, I think this would lead to a poorer UX.



Edit



To download the HTML asynchronously, you should use .get(), instead of .load().



$.get("URL", function(data) {
$(".mydiv").html(data);
});





share|improve this answer























  • I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
    – Mawima
    Nov 22 at 20:17















up vote
0
down vote










up vote
0
down vote









This could easily be achieved by PHP.



<?php
echo file_get_contents("ENTER URL HERE");
?>


You could do this via JavaScript, but that would require making an AJAX request to get the HTML and then inserting it into the DOM. I don't think that this would be the best method as the page would have already loaded without the code and then asynchronously adding it to the page. Depending on how it is meant to be viewed, I think this would lead to a poorer UX.



Edit



To download the HTML asynchronously, you should use .get(), instead of .load().



$.get("URL", function(data) {
$(".mydiv").html(data);
});





share|improve this answer














This could easily be achieved by PHP.



<?php
echo file_get_contents("ENTER URL HERE");
?>


You could do this via JavaScript, but that would require making an AJAX request to get the HTML and then inserting it into the DOM. I don't think that this would be the best method as the page would have already loaded without the code and then asynchronously adding it to the page. Depending on how it is meant to be viewed, I think this would lead to a poorer UX.



Edit



To download the HTML asynchronously, you should use .get(), instead of .load().



$.get("URL", function(data) {
$(".mydiv").html(data);
});






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 24 at 17:31

























answered Nov 22 at 19:22









TheRealBilaal

363




363












  • I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
    – Mawima
    Nov 22 at 20:17




















  • I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
    – Mawima
    Nov 22 at 20:17


















I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
– Mawima
Nov 22 at 20:17






I have two text bars, one of the city and one for the country. The values are passed in the link. I would like, that if I hit a button, the weather status for a city is displayed, like in the screenshot. Can you give me a help please, how I could realize it with JavaScript? I tried it with the JQuery .load method but it doesn't work..
– Mawima
Nov 22 at 20:17




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434842%2finsert-html-content-from-url-into-html-form-div-iframe%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Trompette piccolo

Slow SSRS Report in dynamic grouping and multiple parameters

Simon Yates (cyclisme)