admin管理员组文章数量:1295909
I want to read the html content from given url, but it shows same origin error(I know about this error). So I have tried different method. Open a new window and open the website to that window and read the content from that window, but not work please help me.
Note: This is for my cordova application!
I tried like below
var myWindow=window.open('','','width=200,height=100');
//myWindow.document.write("<p>This is 'myWindow'</p>");
alert(myWindow.innerHTML);
myWindow.document.close();
I want to read the html content from given url, but it shows same origin error(I know about this error). So I have tried different method. Open a new window and open the website to that window and read the content from that window, but not work please help me.
Note: This is for my cordova application!
I tried like below
var myWindow=window.open('http://www.google.','','width=200,height=100');
//myWindow.document.write("<p>This is 'myWindow'</p>");
alert(myWindow.innerHTML);
myWindow.document.close();
Share
Improve this question
edited Jul 14, 2016 at 12:15
Mimouni
3,6303 gold badges31 silver badges37 bronze badges
asked Jul 14, 2016 at 11:15
Asith RajAsith Raj
631 gold badge2 silver badges10 bronze badges
5
- I would try and use a Cordova API – alex Commented Jul 14, 2016 at 11:16
- @alex Can you tell any cordova plugin name for this. – Asith Raj Commented Jul 14, 2016 at 11:17
- If you want to get content from url, i think you should use ajax $.get(...); – Mimouni Commented Jul 14, 2016 at 11:21
- @IlyasMimouni it shown same origin error, like google... – Asith Raj Commented Jul 14, 2016 at 11:23
- @AsithRaj: you have to configure the server by adding some code php, take a look on the anwser here : stackoverflow./questions/23665056/… – Mimouni Commented Jul 14, 2016 at 11:25
1 Answer
Reset to default 5$.get( "http://www.google./", function( data ) {
console.log(data);
});
With help of jQuery, you can get html content of specified URL. Replace your desired URL with "http://www.google./"
. It won't give error in real device or Emulator. But if you will check in Browser then it will give error of CORS.
Regards
本文标签: get the html content from url using jquery or javascriptStack Overflow
版权声明:本文标题:get the html content from url using jquery or javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741619072a2388701.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论