PDA

View Full Version : Problem with different width on .js (ie vs. ff)



Monaco Franze
10-30-2006, 12:22 PM
I use in my board this javascript on the viewforum-page to preview the the first post of a thread when you hover the topic title:



<script language="Javascript" type="text/javascript">
<!--
var agt = navigator.userAgent.toLowerCase();
var originalFirstChild;

function createTitle(which, string, x, y)
{
// record the original first child (protection when deleting)
if (typeof(originalFirstChild) == 'undefined')
{
originalFirstChild = document.body.firstChild;
}

x = document.all ? (event.clientX + document.body.scrollLeft) : x;
y = document.all ? (event.clientY + document.body.scrollTop) : y;
element = document.createElement('div');
element.style.position = 'absolute';
element.style.zIndex = 1000;
element.style.visibility = 'hidden';
excessWidth = 0;
if (document.all)
{
excessWidth = 50;
}
excessHeight = 20;
element.innerHTML = '<div class="quotetitle">Vorschau Fenster</div><div class="quotediv">' + string + '</div>';
renderedElement = document.body.insertBefore(element, document.body.firstChild);
renderedWidth = renderedElement.offsetWidth;
renderedHeight = renderedElement.offsetHeight;

// fix overflowing off the right side of the screen
overFlowX = x + renderedWidth + excessWidth - document.body.offsetWidth;
x = overFlowX > 0 ? x - overFlowX : x;

// fix overflowing off the bottom of the screen
overFlowY = y + renderedHeight + excessHeight - window.innerHeight - window.pageYOffset;
y = overFlowY > 0 ? y - overFlowY : y;

renderedElement.style.top = (y + 15) + 'px';
renderedElement.style.left = (x + 15) + 'px';

// windows versions of mozilla are like too fast here...we have to slow it down
if (agt.indexOf('gecko') != -1 && agt.indexOf('win') != -1)
{
setTimeout("renderedElement.style.visibility = 'visible'", 1);
}
else
{
renderedElement.style.visibility = 'visible';
}
}

function destroyTitle()
{
// make sure we don't delete the actual page contents (javascript can get out of alignment)
if (document.body.firstChild != originalFirstChild)
{
document.body.removeChild(document.body.firstChild);
}
}
//-->
</script>


here the css-arguments:


.quotetitle {
background: #7995DF; border:1px solid #D1D7DC;
font-size: 10px; color: #ECF0F6;
padding:5px; width:90%; font-weight:bold; text-align:left; margin-top:10px;
background: url('images/header_bg.jpg') #589EEE repeat-y left;
}

.quotediv {
background: #fafafa; border: 1px solid #D1D7DC;
font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #444444;
border-top:0; padding:5px; overflow:auto; width:90%; max-height:200px; text-align:left;
}


on Internet Explorer the preview-window that appears when you hover the topic title has always the same width, like it should be.
on firefox, the width of the window is one time very small and the other time very big, it has no static width!

where is the mistake??
what must i change in the code to get a static window size - like on IE - on firefox, too??


thank you!

jscheuer1
10-31-2006, 04:57 PM
It would be easier to diagnose this if you could provide a link to a page where this is used.