0
I saw some examples of loading content into a div
, to specific project pages. But I’m finding it difficult with Jquery.
For page loading it is common to use the function load()
jQuery, which works very well in this case:
$(‘#minhaDiv’).load(‘arquivo.html’);
But there is how I put an external site within a div
specific?
More or less what I did in my code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<title>Exemplo</title>
<!-- ignorem essa parte, quero implementar no futuro para ele exibir a div sem os links do site -->
<!--
<style type="text/css">
.rem-links {
pointer-events: none;
cursor: default;
text-decoration: none;
color: black;
}
#conteudo { width: 400px; height: 300px;
display: none;}
</style>
-->
<script>
$(document).ready(function () {
$("#carregar_site").click(function(){
$("#conteudo").toggle();
$("#conteudo").load('https://www.google.com/');
});
});
</script>
</head>
<body>
<div id="principal">
<button id="carregar_site">Apresentar site externo</button></li>
</div>
<div id="conteudo" class="rem-links"></div>
</body>
</html>
EDIT:
Jeez.... I don’t know how to edit my question. So come on, my solution was the following: I switched out the: $(Document). ready(Function () {
$("#carregar_site").click(function(){
$("#conteudo").toggle();
$("#conteudo").attr("src", "https://www.it-swarm-pt.tech/pt/jquery/como-faco-para-carregar-um-url-no-iframe-com-o-jquery/940370420/");
});
});
</script>
And the DIV #content, by an iframe:
.NOTE: I don’t know how to mark it as finished... if Stackoverflow wants me to mark it as finished. Hug and thank you all.
if you do this you will upload ALL the content of the site, including the tag
html
, which should be unique, this will not look good, is using a function that was not created for that purpose, for this type of functionality should load a single page, or use aiframe
– Ricardo Pontual
The HTML element
<iframe>
– Augusto Vasques
Thanks friends, I do not know how to use the right Stackoverflow tool, so I apologize if I did not respond in the right place or if I failed to put the credits properly thanking you. I edited my question stating what you answered and with my solution.
– Fernando Torres