Posts filed under 'Firefox'

Disable options in a multiple select – Javascript for IE

Yeah, you might be amazed if you thought that just setting the option to disabled would work, even in IE7.
But it looks like it only works on proper browsers.

I searched the net everywhere to see how other people were doing it and I found this method (from: www.lattimore.id.au) to be the best one for my needs. I made some updates to it: I was using a multiple select list and also because I was creating the select box from an AJAX response. So here’s the code:

  1.  
  2. function emulateDisabled(selectBox) {
  3.  for (var i=0, option; option = selectBox.options[i]; i++) {
  4.         if (option.disabled) {
  5.                 option.style.color = "graytext";
  6.         }else{
  7.                 option.style.color = "menutext";
  8.         }
  9.  }
  10. }
  11.  
  12. function restoreEmulateDisabled(selectBox) {
  13.  for (var i=0, option; option = selectBox.options[i]; i++) {
  14.         if(option.selected && option.disabled){
  15.                 option.selected=false;
  16.         }
  17.  }
  18. }
  19.  
  20. function addEmulation(selectBox){
  21.  window.select_current = new Array();
  22.  selectBox.onfocus = function(){ window.select_current[this.id] = this.selectedIndex; }
  23.  selectBox.onchange = function(){ restoreEmulateDisabled(this); }
  24. }
  25.  

If you are generating your select element with AJAX, just call emulateDisabled(your_select_box);
on the onComplete function.
If you would like to have all your select elements to have this functionality then add this onload function:

  1.  
  2. window.onload = function() {
  3.  if (document.getElementsByTagName) {
  4.         var s = document.getElementsByTagName("select");
  5.         if (s.length > 0) {
  6.                 window.select_current = new Array();
  7.                 for (var i=0, select; select = s[i]; i++) {
  8.                         select.onfocus = function(){ window.select_current[this.id] = this.selectedIndex; }
  9.                         select.onchange = function(){ restoreEmulateDisabled(this); }
  10.                         emulateDisabled(select);
  11.                 }
  12.         }
  13.  }
  14. }
  15.  

A big thanks to the guy from lattimore.
cheers mate.

8 comments August 16th, 2007

Firefox 2 and the missing close tabs

Firefox icon logo One thing that I missed from Firefox 1.5 was the close tab button at the end of the tab bar.
I have Firefox 2.0 installed at work but never installed it at home because I missed that feature. I always said I would look into it, and I didn’t want to install a plug-in for that. Finally I checked the config and there it was:

It’s pretty simple using:

about:config

Filter: browser.tabs.closeButton

0 – Display a close button on the active tab only
1 – Display a close button on each tab (default)
2 – Don’t display any close buttons
3 – Display a single close button at the end of the tab bar (Firefox 1.5 behavior)


5 comments June 5th, 2007

Viewing Cache in Firefox, and downloading Flash Files.

Coming from using IE, where you have the “temporary internet files” folder. You get used to getting your swf files from there. But with Firefox if you go to the cache folder:
C:\Documents and Settings\user name\Application Data\Mozilla\Firefox\Profiles\********.default\Cache
You just
don’t get the files.

But if you type this in your firefox address bar:

about:cache?device=memory

…you get a list of files, and can right-click them and download them

Another better way to manage this is with this add-on is: Firefox Cache viewer

Updated: Here’s an image of the add-on:
You don’t get a preview of the SWF files, but you do get a preview of images.

CacheViewer

You can also search and you get a bit more info of each file.


11 comments May 25th, 2007


Calendar

March 2010
M T W T F S S
« May    
1234567
891011121314
15161718192021
22232425262728
293031  

Posts by Month

Posts by Category