I am trying to do something like:
<a href="http://www.google.com">Google</a>
When a user hovers the link:
<div id="display-site">
//working site contained in a div
</div>
Note I am aware that I can open the link in a new window using html, thought I am interested in figuring out how I would go about ‘previewing’ the website contained in the <a> tag, in a div container, (if the link is hovered).
This can be done by creating an
<iframe>in the DOM on hovering over an<a>and loading thehrefas the iframe’ssrc=attribute. In order to make it look like a popup, you would need to position the<iframe>at an absolute location, and set itsz-indexCSS property to a higher value than the rest of the page content.However, if you need to make modifications to the display of the loaded frame, such as sizing some elements to accommodate the zoom level as suggested by @David’s answer, you may run afoul of the same-origin policy, as scripts will not be permitted to access properties of the loaded frame outisde the same domain.
From MDN: