Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace Iframe with Ajax

My project is to have preview of some websites inside my website, I'm using Iframe for now to load the website preview and then the user can interact within the Iframe.

I have to change the Iframe implementation to be within the page For SEO purpose, So what could be the replacement is Jquery .load() function.

$('div#websitePreview').load('Website_URL');

but the problem is when the user interact with the website (click some link) the whole page will redirect to the new link, so is there a way to load the page which been clicked by the user in the same div by ajax call without leaving my website?

UPDATE: The websites I'm going to preview have subdomains of my original site

like image 689
Farok Ojil Avatar asked Jun 01 '26 07:06

Farok Ojil


1 Answers

There is no way to achieve this, due cross domain security restrictions in modern browsers. You aren't allowed to access other domains content via ajax.

The other point is, that you may have css bugs if you load an entry page in a div on your site, because the loaded css will override your site's css.

like image 107
Martin Lantzsch Avatar answered Jun 03 '26 19:06

Martin Lantzsch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!