{"id":436,"date":"2007-01-11T17:08:55","date_gmt":"2007-01-12T00:08:55","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/2007\/01\/11\/how-to-remove-elements-from-a-listbox-in-javascript-ie-and-firefox\/"},"modified":"2007-01-11T17:08:55","modified_gmt":"2007-01-12T00:08:55","slug":"how-to-remove-elements-from-a-listbox-in-javascript-ie-and-firefox","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/how-to-remove-elements-from-a-listbox-in-javascript-ie-and-firefox\/","title":{"rendered":"How to remove elements from a listbox in Javascript (IE and Firefox)"},"content":{"rendered":"<pre>\n\/\/By Gubatron, just a silly function to clear the contents of a listbox object\nvar ua = navigator.userAgent.toLowerCase();\nvar Browser = new Object()\nBrowser.isIE = window.ActiveXObject ? true : false;\nBrowser.isFirefox = (ua.indexOf(\"firefox\")!=-1);\n\nfunction clearListbox(listboxObject) {\t\n\tif (Browser.isFirefox) {\n\t    \/\/in firefox \"Option\" objects remove themselves.\n            var options = listboxObject.options\n\t    while (options.length > 0) {\n\t\t    options[options.length-1].remove()\n\t    }\n\t} else {\n\t\t\/\/in IE the Options array, which contains \"Option\" objects, is the one in charge of removal\n\t\twhile (listboxObject.options.length > 0) {\n\t\t\tlistboxObject.options.remove(0)\n\t\t}\t\t\n\t}\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/By Gubatron, just a silly function to clear the contents of a listbox object var ua = navigator.userAgent.toLowerCase(); var Browser = new Object() Browser.isIE = window.ActiveXObject ? true : false; Browser.isFirefox = (ua.indexOf(&#8220;firefox&#8221;)!=-1); function clearListbox(listboxObject) { if (Browser.isFirefox) { \/\/in firefox &#8220;Option&#8221; objects remove themselves. var options = listboxObject.options while (options.length > 0) { options[options.length-1].remove() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,30],"tags":[],"class_list":["post-436","post","type-post","status-publish","format-standard","hentry","category-code","category-geeklife"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-72","jetpack-related-posts":[{"id":402,"url":"https:\/\/www.gubatron.com\/blog\/an-useful-example-on-how-to-extend-javascript\/","url_meta":{"origin":436,"position":0},"title":"An useful example on how to extend Javascript","author":"gubatron","date":"November 29, 2006","format":false,"excerpt":"Today I found out I could extend the functionality of __EXISTING__ html classes with javascript. I was manipulating DOM objects, better known as HTMLElement objects, and I needed a way to print the HTML that represents the tag of the object, not what's contained by the tags... a friend told\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":352,"url":"https:\/\/www.gubatron.com\/blog\/internet-explorer-javascript-vs-firefox-ajax-error-recovery-in-firefox\/","url_meta":{"origin":436,"position":1},"title":"Internet Explorer Javascript vs Firefox: AJAX Error Recovery in Firefox","author":"gubatron","date":"August 4, 2006","format":false,"excerpt":"After a good 4 hours or more, we finally found the error, it was our bad, but Firefox was helping us, Internet Explorer was keeping the standards but not reporting a warning or recovering from our fault... We're currently using a complex ajax call that needs to pass a bunch\u2026","rel":"","context":"In &quot;AJAX&quot;","block_context":{"text":"AJAX","link":"https:\/\/www.gubatron.com\/blog\/category\/ajax\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":279,"url":"https:\/\/www.gubatron.com\/blog\/xul-in-ie\/","url_meta":{"origin":436,"position":2},"title":"XUL in IE","author":"gubatron","date":"March 28, 2006","format":false,"excerpt":"I strongly believe the REAL web 2.0 applications will run on something called XUL, as it is the web 1.9 not only runs on fancy javascript (aka AJAX), but it already does use XUL. You might not know what XUL is, but if you' ve been using Firefox, you' ve\u2026","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":308,"url":"https:\/\/www.gubatron.com\/blog\/useful-firefox-extensions\/","url_meta":{"origin":436,"position":3},"title":"Useful Firefox extensions","author":"gubatron","date":"May 2, 2006","format":false,"excerpt":"Here's a page I've been meaning to do a long time ago, if you're a web developer you might want to bookmark it so that next time you set up Firefox +1.5 you'll have direct links to all the web developer tools you'll ever need. Web Developer Extension (Best extension\u2026","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":268,"url":"https:\/\/www.gubatron.com\/blog\/firefox-16-might-include-python-interpreter-script-typetextpythondef-helloworld-script\/","url_meta":{"origin":436,"position":4},"title":"Firefox 1.6 might include Python interpreter:","author":"gubatron","date":"March 3, 2006","format":false,"excerpt":"Rumors say Google engineers are working on a branch of code that will allow embedding python code on the client side. It seems finally we won't have to deal with an Object Based language (javascript) which makes sense... Now we'll have a true Object Oriented language running on the backend\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":116,"url":"https:\/\/www.gubatron.com\/blog\/mi-franela-de-firefox\/","url_meta":{"origin":436,"position":5},"title":"Mi Franela de Firefox","author":"gubatron","date":"March 9, 2005","format":false,"excerpt":"Es un poco trizte escuchar las noticias esta semana sobre la falta de motivacion en el proyecto Firefox. Pienso que esta noticia fue publicada por 2 posibles razones: 1.- Microsoft y otros Browsers queriendo bajar los animos de los usuarios que apoyamos Firefox, la guerra contra Firefox ha empezado. 2.-\u2026","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=436"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/436\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}