Cyclone
11-02-2008, 07:01 AM
Hi,
I am trying to get the pages of my site to validate and render as close as possible in Firefox and IE. So far I got them to validate and everything renders the same in both browsers except for the position of the tooltip window in relation to the mouse cursor.
As you can see in the image below they don’t match up. I was able to solve this by using browser detection code and adding a margin of 2px.
// if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {tipcss.margin='2px';}
http://www.inspiredvisuals.com/Cgtalk/test.jpg
Script
// Resize window (Maximize). //
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
// End of resize Code. //
/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine.
* Note this is an edited version. See link below for the original script.
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
// I replaced the 'tipcss.visibility' property throughout the original script with 'tipcss.display' to remove a bug that occurred when using an IFRAME inside the tooltip window. Some of the contents(table borders) in the IFRAME window would not disappear after the hidetip() function was called.
// The 'Xposition' and 'Yposition' variables were added to the 'doTooltip()' function so that the x/y tooltip offset positions can be specified seperately for each tooltip link.
var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;
var origWidth, origHeight;
var t1,t2;
var tipOn = false;
if (nodyn) { event = "nope" }
/////////////////////// CUSTOMIZE HERE ////////////////////
var tipFollowMouse= true;
var offX= 0; // Don't change the offX/offY positions here.
var offY= 0; // You can specify their values in the link code(onMouseover).
var tipFontFamily= "Arial";
var tipFontSize= "8pt";
var tipFontColor= "#7C92B8";
var tipBgColor= "#212630";
var tipBorderColor= "#276F91";
var tipBorderWidth= 3;
var tipBorderStyle= "Solid";
var tipPadding= 0;
if (tipHeight==0) {tipHeight=800}; if (tipWidth==0) {tipWidth=404}; // This line sets the defualt iframe height and width.
//////////////////// END OF CUSTOMIZATION AREA ///////////////////
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = messages[i][0];
}
}
var startStr = '<table style="width:' + tipWidth + 'px;border-collapse:collapse"><tr><td style="height:' + tipHeight +'px;padding:0px"><IFRAME src="'; // These two lines contain html(etc) code which is used to create the contents of the tooltip window.
var endStr = '" style="width:' + (tipWidth - 2) + 'px;height:' + (tipHeight - tipBorderWidth) + 'px" frameborder="0" onMouseover="clearTimeout(t2)" onMouseout="hideTip(1)"</td></tr>';
var tooltip, tipcss;
function initTip()
{
if (nodyn) return;
tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
tipcss = tooltip.style;
if (ie4||ie5||ns5) {
tipcss.width = 'auto';
tipcss.fontFamily = tipFontFamily;
tipcss.fontSize = tipFontSize;
tipcss.color = tipFontColor;
tipcss.backgroundColor = tipBgColor;
tipcss.borderColor = tipBorderColor;
tipcss.borderWidth = tipBorderWidth+"px";
tipcss.padding = tipPadding+"px";
tipcss.borderStyle = tipBorderStyle;
tipcss.textAlign='center';
tipcss.margin='0px auto';
}
// if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {tipcss.margin='2px';}
if (tooltip&&tipFollowMouse) {
document.onmousemove = trackMouse;
}
}
window.onload = initTip;
function doTooltip(evt,num,Xposition,Yposition)
{
if (!tooltip) return;
if (t1) clearTimeout(t1);
if (t2) clearTimeout(t2);
tipOn = true;
offX = Xposition
offY = -Yposition - tipHeight
if (messages[num][2]) var curBgColor = messages[num][2];
else curBgColor = tipBgColor;
if (messages[num][3]) var curFontColor = messages[num][3];
else curFontColor = tipFontColor;
if (ie4||ie5||ns5) {
var tip = startStr + messages[num][0] + endStr;
tipcss.backgroundColor = curBgColor;
tooltip.innerHTML = tip;
}
if (!tipFollowMouse) positionTip(evt);
else t1=setTimeout("tipcss.display='block'",100);
}
var mouseX, mouseY;
function trackMouse(evt) {
standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
if (tipOn) positionTip(evt);}
function positionTip(evt)
{
if (!tipFollowMouse)
{
standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
}
var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
if ((mouseX+offX+tpWd)>winWd)
tipcss.left = mouseX-(tpWd+offX)+"px";
else tipcss.left = mouseX+offX+"px";
if ((mouseY+offY+tpHt)>winHt)
tipcss.top = winHt-(tpHt+offY+Yposition)+"px";
else tipcss.top = mouseY+offY+"px";
if (!tipFollowMouse) t1=setTimeout("tipcss.display='block'",100);
}
function hideTip(mouseout)
{
if (mouseout==1)
{
tipOn = false;
t2=setTimeout("tipcss.display='none'",286);
document.getElementById('link1').blur();
}
else
{
if (tipOn==true)
{
tipOn = false;
t2=setTimeout("tipcss.display='none'",100);
document.getElementById('link1').blur();
}
else
{
tipOn=true;
tipcss.display='block';
}
}
}
document.write('<div id="tipDiv" style="position:absolute; display:none; z-index:100"></div>')
But I don’t want to have to resort to this method. I’m sure its possible without it. It seems there’s an extra 2px margin around the tooltip window in Firefox. Anyone know how to remove this? I tried so many things but still couldn’t figure it out. :(
Thanks.
Have a good weekend.
I am trying to get the pages of my site to validate and render as close as possible in Firefox and IE. So far I got them to validate and everything renders the same in both browsers except for the position of the tooltip window in relation to the mouse cursor.
As you can see in the image below they don’t match up. I was able to solve this by using browser detection code and adding a margin of 2px.
// if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {tipcss.margin='2px';}
http://www.inspiredvisuals.com/Cgtalk/test.jpg
Script
// Resize window (Maximize). //
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
// End of resize Code. //
/***********************************************
* Image w/ description tooltip- By Dynamic Web Coding (www.dyn-web.com)
* Copyright 2002-2007 by Sharon Paine.
* Note this is an edited version. See link below for the original script.
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
// I replaced the 'tipcss.visibility' property throughout the original script with 'tipcss.display' to remove a bug that occurred when using an IFRAME inside the tooltip window. Some of the contents(table borders) in the IFRAME window would not disappear after the hidetip() function was called.
// The 'Xposition' and 'Yposition' variables were added to the 'doTooltip()' function so that the x/y tooltip offset positions can be specified seperately for each tooltip link.
var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;
var origWidth, origHeight;
var t1,t2;
var tipOn = false;
if (nodyn) { event = "nope" }
/////////////////////// CUSTOMIZE HERE ////////////////////
var tipFollowMouse= true;
var offX= 0; // Don't change the offX/offY positions here.
var offY= 0; // You can specify their values in the link code(onMouseover).
var tipFontFamily= "Arial";
var tipFontSize= "8pt";
var tipFontColor= "#7C92B8";
var tipBgColor= "#212630";
var tipBorderColor= "#276F91";
var tipBorderWidth= 3;
var tipBorderStyle= "Solid";
var tipPadding= 0;
if (tipHeight==0) {tipHeight=800}; if (tipWidth==0) {tipWidth=404}; // This line sets the defualt iframe height and width.
//////////////////// END OF CUSTOMIZATION AREA ///////////////////
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = messages[i][0];
}
}
var startStr = '<table style="width:' + tipWidth + 'px;border-collapse:collapse"><tr><td style="height:' + tipHeight +'px;padding:0px"><IFRAME src="'; // These two lines contain html(etc) code which is used to create the contents of the tooltip window.
var endStr = '" style="width:' + (tipWidth - 2) + 'px;height:' + (tipHeight - tipBorderWidth) + 'px" frameborder="0" onMouseover="clearTimeout(t2)" onMouseout="hideTip(1)"</td></tr>';
var tooltip, tipcss;
function initTip()
{
if (nodyn) return;
tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
tipcss = tooltip.style;
if (ie4||ie5||ns5) {
tipcss.width = 'auto';
tipcss.fontFamily = tipFontFamily;
tipcss.fontSize = tipFontSize;
tipcss.color = tipFontColor;
tipcss.backgroundColor = tipBgColor;
tipcss.borderColor = tipBorderColor;
tipcss.borderWidth = tipBorderWidth+"px";
tipcss.padding = tipPadding+"px";
tipcss.borderStyle = tipBorderStyle;
tipcss.textAlign='center';
tipcss.margin='0px auto';
}
// if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {tipcss.margin='2px';}
if (tooltip&&tipFollowMouse) {
document.onmousemove = trackMouse;
}
}
window.onload = initTip;
function doTooltip(evt,num,Xposition,Yposition)
{
if (!tooltip) return;
if (t1) clearTimeout(t1);
if (t2) clearTimeout(t2);
tipOn = true;
offX = Xposition
offY = -Yposition - tipHeight
if (messages[num][2]) var curBgColor = messages[num][2];
else curBgColor = tipBgColor;
if (messages[num][3]) var curFontColor = messages[num][3];
else curFontColor = tipFontColor;
if (ie4||ie5||ns5) {
var tip = startStr + messages[num][0] + endStr;
tipcss.backgroundColor = curBgColor;
tooltip.innerHTML = tip;
}
if (!tipFollowMouse) positionTip(evt);
else t1=setTimeout("tipcss.display='block'",100);
}
var mouseX, mouseY;
function trackMouse(evt) {
standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
if (tipOn) positionTip(evt);}
function positionTip(evt)
{
if (!tipFollowMouse)
{
standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
}
var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
if ((mouseX+offX+tpWd)>winWd)
tipcss.left = mouseX-(tpWd+offX)+"px";
else tipcss.left = mouseX+offX+"px";
if ((mouseY+offY+tpHt)>winHt)
tipcss.top = winHt-(tpHt+offY+Yposition)+"px";
else tipcss.top = mouseY+offY+"px";
if (!tipFollowMouse) t1=setTimeout("tipcss.display='block'",100);
}
function hideTip(mouseout)
{
if (mouseout==1)
{
tipOn = false;
t2=setTimeout("tipcss.display='none'",286);
document.getElementById('link1').blur();
}
else
{
if (tipOn==true)
{
tipOn = false;
t2=setTimeout("tipcss.display='none'",100);
document.getElementById('link1').blur();
}
else
{
tipOn=true;
tipcss.display='block';
}
}
}
document.write('<div id="tipDiv" style="position:absolute; display:none; z-index:100"></div>')
But I don’t want to have to resort to this method. I’m sure its possible without it. It seems there’s an extra 2px margin around the tooltip window in Firefox. Anyone know how to remove this? I tried so many things but still couldn’t figure it out. :(
Thanks.
Have a good weekend.