Open an external website in the Google Chrome Extension

So, I'm trying to access Google Chrome extensions.

I already made a 50% script, but I settled on one step:

How to load an external website - for example: www.mysite.com/page.php - in popup.html?

I only had success when I used iFrame, but, it's ugly and insecure ... :(

Is there a way to do this using jquery (ajax)?

Thanks in advance.


So, here is how my manifest.json is:

{ "manifest_version": 2, "name": "XCLickF", "description": "X file", "version": "1.0", "background": { "scripts": ["jquery-1.9.1.min.js","background.js"] }, "permissions": [ "http://*/*", "https://*/*" ], "browser_action": { "default_icon": "icon.png", "default_title": "XMail", "default_popup": "popup.html" } } 

And like my background.js:

 function poll() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = handleStateChange; // Implemented elsewhere. xhr.open("GET", 'http://disqus.com/', false); xhr.send(null); console.log(xhr.responseText); } function handleStateChange() { if (this.readyState == 4) { var resp = JSON.parse(this.responseText); updateUi(resp); } } function updateUi(json) { console.log("JSON: ", json); } 
+4
source share
1 answer

In fact, you can get all the html of this page using jquery ajax (or xhr). After receiving the html you should create / execute js'. You can also redirect to your web page (but basically this can lead to a ban from the Google store). You cannot display a page without using an iframe.

 $.ajax({ url: 'www.google.com', success: function(data) { console.log(data); // data gives all of html } }); 

You can also use iframe cross-platform plugins that can help your work.

Iframe height jquery plugin

Iframe resizer

0
source

Source: https://habr.com/ru/post/1483490/


All Articles