Archive for August, 2007

External display seems blurred on Mac

Even Macs do weird things. If you’ve connected a second display to your Mac it might be a false identification which makes your screen really blurry or even display an “Out of sync” message. This can be fixed easily in OS X by removing or renaming the file Library/Preferences/com.apple.windowserver.plist and rebooting your Mac — that last step is in most cases not even necessary.


Keep Firefox tabs between sessions

When you close Firefox you’ll get a warning to lose all current open tabs and until recently I didn’t know there was an option available to save your current session. If you open the preferences of Firefox, you’ll see the screen as shown below. Select the option: ‘When Firefox starts: Show my windows and tabs from last time’ and you’ll be set to go. Restart Firefox and notice that your tabs still exists.

firefox_tabs.png


Retrieving a self defined attribute with Javascript

In some rare cases you might want to add a self defined attribute to an element. This can be handy to store additional data you might need in your application. Take the following HTML code for example:

<form name="clientEdit" action="/client.php" method="POST">
<!-- ...other form stuff here... -->
<select name="client">
    <option id="1" billable="1">Clint</option>
    <option id="2" billable="0">Steve</option>
    <option id="3" billable="1">Chris</option>
    <option id="4" billable="1">Rick</option>
</select>

The added attribute ‘billable’ will be used to check if a client can be billed by our application. Using javascript you can disable the invoice button or display an alert when a non-billable client — in this case Steve — has been selected.

To get the billable attribute you can use the getAttribute() function like in the following example.

/* <![CDATA[ */
function createInvoice()
{
    with(document.forms['clientEdit'])
    {
        if(client.options[client.selectedIndex].getAttribute('billable') == 1)
        {
            alert("Client is billable, create the invoice");
        }
    }
}
/* ]]> */

As you can see, it’s simple to get the value of the attribute.


Copyright © 1996-2010 Re:morse.nl. All rights reserved.
iDream theme by Templates Next | Powered by WordPress