joeami Posted May 10, 2010 Share Posted May 10, 2010 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 Quote Link to comment Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 How are you requesting the content? Quote Link to comment Share on other sites More sharing options...
joeami Posted May 11, 2010 Author Share Posted May 11, 2010 Hi Adam, The content is returned via curl_exec. Regards Quote Link to comment Share on other sites More sharing options...
Adam Posted May 11, 2010 Share Posted May 11, 2010 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. Quote Link to comment Share on other sites More sharing options...
joeami Posted May 20, 2010 Author Share Posted May 20, 2010 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.