Alternative to <td nowrap>

I found this link to be very helpful for dealing with nowrap.

This may seem trivial but interesting. In the world of compliance with XHTML 1.0 the best approach I have found to the nowrap attribute is in CSS white-space attribute, examples …

<td style="white-space: nowrap;">
<a style="white-space: nowrap;">

http://blogs.msdn.com/mab/archive/2006/01/18/514522.aspx

Advertisements
Posted in CSS, HTML. Tags: , . Leave a Comment »

Cancel mouse event cross browser

I had an issue this week with a form element that was contained inside a DIV. The DIV had a onclick event as well as the form element. I wanted the form element to do its work and then stop the DIV’s onclick event. Through a lot of searching and help from some co-workers I came up with this script that works pretty well. I have tested it with IE6, IE7 and FF 3.

 <asp:Label ID="lblOptions" onclick="return CancelEventReturnFalse(event);" runat="server" Text="Options"></asp:Label>
function CancelEventReturnFalse(e) {

    try {

        if (e) {
            e.returnValue = false;
            e.cancelBubble = true;

            if (e.stopPropagation) {
                e.stopPropagation();

            }
            if (e.preventDefault) {
                e.preventDefault();
            }

        }

    } catch (c) {alert(c); }

    return false;

}

IE6: Set OBJECT tag width and height dynamically

I had an issue this week with IE6 and the OBJECT tag.  The real issues is supporting IE6, but that’s another battle all together.

I was trying to use percentage based width and height on the OBJECT tag.  In IE6 this always rendered nothing.  IE7 and Firefox worked fine. If I used a fixed width and height for IE6 it worked.

Apparently IE6 did not implement the W3C standard for width and height on the OBJECT tag.

My solution was to use some JavaScript for getting the screen resolution and then calculating the percentage.  It wasn’t what I wanted but it worked.

function SetObjectTagProps(id)
{

    var obj = document.getElementById(id);
    obj.width = (GetWidth() * 0.95);
    obj.height = (GetHeigth() * 0.95);

}

function GetWidth()
{
    var myWidth = 0
    if (typeof (window.innerWidth) == 'number')
    {
        //Non-IE
        myWidth = window.innerWidth;

    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;

    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight))
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;

    }
    //alert('Width = ' + myWidth);

    return myWidth;
}

function GetHeigth()
{
    myHeight = 0;
    if (typeof (window.innerWidth) == 'number')
    {
        //Non-IE
        myHeight = window.innerHeight;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;

    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight))
    {
        //IE 4 compatible
        myHeight = document.body.clientHeight;

    }

    //alert('Height = ' + myHeight);

    return myHeight;
}