www.netsi.dk

"The internet is just a layer on the real world" (don't forget that!)

How-to: Making elements unselectable using CSS user-select

I just discovered that a very clean and easy to use soloution exists where you using CSS can make elements . Sometimes you do not want the content of some elements selectable, so with this soloution you can simply add a class “”.

 

The syntax

You can see links to pages containing more info, but the syntax is “” with vendor prefixes. The values are “none | text | toggle | element | elements | all | inherit” according to a draft specifications on w3c. I am not sure if Opera actually has implementer this feature.

Example

This block you can select (default action).

 

This block you cannot select as it has the class “unselectable” applied.

 

dummyimage.com lets you create image in given size and colour just using an URLYou can select the text but not the image, it has “textOnlySelectable”

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.

The code


.unselectable {
        -moz-user-select: none;
        -khtml-user-select: none;
        -webkit-user-select: none;
        -o-user-select: none; 

        -ms-user-select: none;
        user-select: none;
}

.textOnlySelectable {
        -moz-user-select: text;
        -khtml-user-select: text;
        -webkit-user-select: text;
        -o-user-select: text; 

        -ms-user-select: text;
        user-select: text;
}

 

Links
Share

Avoiding the advertisement in MSN Live messenger, and many other places (browser for instance).

Notice: No add at the bottom of the MSN Live Messenger client I don’t know how you feel about having tons and tons of advertisements showing at the bottom of your Windows Live Messenger client (WLM), but it annoys me. But don’t worrie help is on the way! I will give you a WLM specifik fix and a description to avoid many adds in your browser and other places.

I had an error showing up today during init of WLM, and so I let the Microsoft Visual Studio debugger start up. Inside that I could locate the address – host name – of the host which deliveres the adds.

I was now ready to follow the advice from a collegue of mine given in another context. The advice was to add an entry to the hosts file on your computer which would bind the add server hostname to 127.0.0.1. By doing that you effectively makes it impossibel for the add handling software to show any adds!

So what you need to add to do is:

  • Open the “C:\Windows\System32\drivers\etc\hosts” file in an editor
  • Add this line: 127.0.0.1 track.adform.net

The effect is that any request to “track.adform.net” will be pointing to your own computer – effectively disabling the adds! :-)

The next step – disabling any adds inside webpages (or anywhere else) from a list of add servers.

I have at this time not gone deeper into this step, but a simpel google on “hostnames for add servers” gave me this link: Ad blocking with ad server hostnames and IP addresses. Just choose the “hosts – in host file format”. Here is a direct link to a test I made. Actually the host mentioned at the start of this post is inside the list :-)

Happy add blocking!

Update 8th january 2011

Just wanted to clearify how this way of doing add blocking works, so here is a quote from the website providing the serverlist for your hosts file:

From “http://pgl.yoyo.org/as/” the page providing serverlists for your hosts file:
The ad banners that you see all over the web are stored on servers. Stopping your computer communicating with another computer can be quite simple. So, if you have a list of the servers used for ad banners, it’s easy to stop ad banners even getting to your browser.

Updated 2011-05-20

The program you want to use to change the hosts file with will in windows 7 need to have administrative rights. So you should use the “Run as administrator…” option you get when right clicking on the noteblok. This will allow you to make changes to the hosts file.

Another thing is that after you have added the domains to the hosts file you need to flush the DNS. The local DNS database contains relations between hostnames and IP-addresses, and if you do not flush that, the add servers can still be reached until next time the DNS system need to get a hostname-IP address relation. So open a Run window (press windows-key + R for instance) and enter “ipconfig /flushdns”. Now there does not exist any relation between any domain and IP-address. The next time a DNS lookup for a addserver hostname is done, an ip address of 127.0.0.1 (your local computer) is returned, making it impossibel for the addserver to get its adds :-)

Share

Cant send e-mails? Try changing port number for outgoing e-mail to 26!

I have had problems sending e-mails from my client (Windows Live Mail) and must admit that firstly I suspected the Microsoft product as the problem. Well that fact that Microsoft often is blamed for things which actually not is their fault is another story!

I asked the support from gullestrup.net and they suggested that it was my service provider (Danish company TDC). Sometimes they block traffic on the default port 25 (used for outgoing traffic), so I simply should change port for outgoing traffic to 26.

So today I changed changing it under the Account advanced settings in Windows Live Mail, and voila! I can send e-mails again! :-)

Share