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!
javascript html css iframe
add a comment |
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!
javascript html css iframe
Will the content be an image?
– Christheoreo
Nov 22 at 16:20
add a comment |
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!
javascript html css iframe
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
javascript html css iframe
asked Nov 22 at 16:15
Mawima
11
11
Will the content be an image?
– Christheoreo
Nov 22 at 16:20
add a comment |
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
add a comment |
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>"
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
add a comment |
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);
});
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
add a comment |
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>"
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
add a comment |
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>"
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
add a comment |
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>"
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>"
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
add a comment |
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
add a comment |
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);
});
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
add a comment |
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);
});
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
add a comment |
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);
});
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);
});
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Will the content be an image?
– Christheoreo
Nov 22 at 16:20