manipulate another webpage via javascript

1

is the following, I need to access a site and search through my page. I'm trying this way:

<html> <script type="text/javascript" src="js/jquery.js"> </script>

<div class="news">  <iframe src="http://alelo.com.br/consulta-saldo-extrato-alelo.html"style="width:100%; height:100%; float:left;" frameborder="0" id = "jones"></iframe> </div>

<input type = "text" id = "piru">

<script> document.getElementById('jones').onload= function() {      var valor = $('#jones').contents().find('#numero').val();  alert(valor);    }

</script> </html> 

I can not do anything on the page inside the iframe ... Help!

    
asked by anonymous 29.05.2015 / 16:53

1 answer

1

If the site is not in the same domain as yours then you will not be able to access the site. This has to do with security rules ( CORS ) to prevent a JavaScript page from being manipulated via iFrame.

The error that gives you is possibly this ( coming from this example ):

  Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin " link " from accessing a frame with origin " link ". Protocols, domains, and ports must match.

    
29.05.2015 / 16:57