Results 1 to 2 of 2

Thread: Problem with different width on .js (ie vs. ff)

  1. #1
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Problem with different width on .js (ie vs. ff)

    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:

    Code:
    <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:
    Code:
    .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!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It would be easier to diagnose this if you could provide a link to a page where this is used.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •