Jump to content

How to display an external page without breaking external resources


joeami

Recommended Posts

Hi All,

 

I'm developing a small app where I display an HTML page on a browser to end users. The closest thing to what I'm trying to do would be Google's cache functionality. For example, let's say someone decided to use my app and requests that google.com be display, then my app would display a copy of google.com's index/content on the browser. Because this is done via mydomain.tld, mydomain.tld is the document.domain.

 

Which brings me to the problem, if google has a href or img with a src="/image.jpg" with window.onload(), the browser would attempt to pull http://mydomain.tld/image.jpg and therefore breaks the page display.

 

My question is how do I force the browser to inject the correct domain name? mydomain.tld so in control of the DOM. But I'm not sure how to get there.

 

Any help is appreciated.

 

Regards

You'll need to manually replace every relative URL, I'd suggest using the DOM extension as opposed to regexp or something like that. Have a play around, load the HTML with the loadHTML method, navigate through the child nodes and see what you can do.

 

When you get stuck come back and I'll gladly help you, but you'll learn a lot more if you attempt this yourself.

  • 2 weeks later...

You'll need to manually replace every relative URL, I'd suggest using the DOM extension as opposed to regexp or something like that. Have a play around, load the HTML with the loadHTML method, navigate through the child nodes and see what you can do.

 

When you get stuck come back and I'll gladly help you, but you'll learn a lot more if you attempt this yourself.

 

Thanks for your help. I'm now able to work around the broken images part. I have another issue I need help with. I'll open a new thread on that.

 

Best

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.