[英]Capture div another page or jQuery javascript
I want to load in a local page , only the elements LOGIN , PASSWORD , REGISTER , another external page in another domain, without loading the entire layout of it , only these three elements. 我想只在本地页面中加载元素LOGIN,PASSWORD,REGISTER,另一个域中的另一个外部页面,而不加载它的整个布局,仅加载这三个元素。
I've tried that way , seeking to identify the element: 我尝试过这种方法,试图确定元素:
$.ajax({
url: 'http://www.sptrans.com.br/sac/solicitacoes.aspx',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).find('vUSRLOGA');
$("#conteudo").html(headline);
}
});
and 和
$.ajax({
url: 'http://www.sptrans.com.br/sac/solicitacoes.aspx',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).text();
$("#conteudo").html(headline);
}
})
I want the elements normally be presented in order to give login or register . 我希望通常显示这些元素以便进行登录或注册。
the current way , behind only the text of the page and not the functional elements 当前方式,仅在页面文本后面,而不在功能元素后面
Full Code: 完整代码:
<!DOCTYPE HTML>
<html lang="pt-br">
<head>
<!-- Scripts Javascript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://projetos.lucaspeperaio.com.br/ajax-cross-domain/jquery.xdomainajax.js"></script>
<script type="text/javascript">
/*$.ajax({
url: 'http://www.sptrans.com.br/sac/solicitacoes.aspx',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).text();
$("#conteudo").html(headline);
}
});*/
$.ajax({
url: 'http://www.sptrans.com.br/sac/solicitacoes.aspx',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).find('vUSRLOGA');
$("#conteudo").html(headline);
}
});
</script>
<title>Teste</title>
<body>
<div id="conteudo" style="background:#EEF0A6"></div>
</body>
</html>
I want to show ONLY the part that is inside the red square: 我只想显示红色方块内的部分:
As I understood, you have a website that wants access another website. 据我了解,您有一个网站想要访问另一个网站。 It can't be done in javascript because of cross-domain policy.
由于跨网域政策,因此无法在JavaScript中完成。
Find element attributes on different domain using Javascript 使用JavaScript在其他域上查找元素属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.