Hola
Como no tengo claro a que exactamente te refieres cuando hablas de centrar, prueba con esto
Código Javascript
:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
window.onload = function () {
ligas = document.getElementById('enlaces').getElementsByTagName('A');
for(i= 0; i < ligas.length; i++) {
ligas[i].onmouseover = prev;
ligas[i].onmouseout = prev;
}
}
function prev(evento){
var evento = evento || window.event;
switch(evento.type) {
case 'mouseover':
window.c=document.createElement('div');
c.style.position='absolute';
var pos=getElementPosition.call(this);
c.style.left=pos.left+'px';
c.style.top=pos.top+'px';
c.style.padding='2px';
c.style.border='1px solid #000';
c.innerHTML='<iframe width="500" height="300" frameborder="0" allowtransparency="true" src="'+this.href+'" />';
document.body.appendChild(c);
break;
case 'mouseout':
document.body.removeChild(window.c);
window.c=null;
break;
}
}
function getElementPosition() {
var offsetTrail = this;
var offsetLeft = 0;
var offsetTop = 0;
var window_height = ieNOTopera? iecompattest().clientHeight : window.innerHeight;
var window_width = ieNOTopera? iecompattest().clientWidth : window.innerWidth;
while (offsetTrail.offsetParent) {
// offsetLeft += offsetTrail.offsetLeft;
offsetTop += offsetTrail.offsetTop;
offsetTrail = offsetTrail.offsetParent;
}
offsetLeft = parseInt(((window_width) / 2) - 250); // menos mitad del width del iframa
if (offsetTop < window_height) {
offsetTop = parseInt(((screen.height) / 2) - 200);
}else {
offsetTop = (offsetTop /2 -100);
}
return {left:offsetLeft, top:offsetTop};
}
var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1
function iecompattest() {
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
</script>
</head>
<body>
<div id="enlaces">
<a id="caricatos" href="http://www.caricatos.net/">caricatos.net</a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<a id="forosweb" href="http://www.forosdelweb.com/">forosdelweb.com</a><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<a id="desweb" href="http://www.desarrolloweb.com/">desarrolloweb.com</a>
</div>
</body>
</html>
Suerte