Showing posts with label Mozilla Firefox. Show all posts
Showing posts with label Mozilla Firefox. Show all posts

Monday, February 24, 2014

Hiding a Option element in your webpage

By applying a style="display:none" to the <option> element in your webpage will not give you the desired results across all the browsers. Therefore, you either remove or add the <option> element when needed or create 2 different set of <select> element to provide the user the correct set of menu.

Here's the source code of the page that I have created, try viewing it using different browsers like 'Internet Explorer', 'Mozilla Firefox' and 'Google Chrome' and you can spot the difference.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hide a menu option</title>
</head>
<body>
Fruits:
<select>
    <option value="apple">Apple</option>
    <option value="orange">Orange</option>
    <option value="pear" style="display:none">Pear</option>
    <option value="pineapple">Pineapple</option>
</select>
</body>
</html>
* Click here for the demo shown in this post.

Thursday, June 13, 2013

HTML: Background Colour with Opacity

Well, I was working the other day and one of my colleagues told me that the div that has a background colour with an opacity of 70 doesn't work in IE. After a bit of Googling and a bit of trial and error, I managed to get it working. (It works in Google Chrome, Mozilla Firefox, Internet Explorer 7, 8 and 9. However, the solution doesn't really work with Internet Explorer with different standards.)

Let's go through parts of the source codes first. The following liner will enforce your Internet Explorer 9 onwards to fall back and use Internet Explorer 8 standards. However, this will also caused all your Internet Explorer 9 codes to malfunction.
<meta http-equiv="X-UA-Compatible" content="IE=8" >
The following codes are meant for super old browsers that doesn't supports the css RGBa(3 primary colours and alpha).
/* Fallback for web browsers that doesn't support RGBa */
background: rgb(0, 0, 0) transparent;
The following codes are meant for super new browsers that supports the css RGBa(3 primary colours and alpha). (For example: latest Mozilla Firefox, Google Chrome, etc.)
/* RGBa with 0.7 opacity */
background: rgba(0, 0, 0, 0.7);
The following codes are meant for the older Internet Explorers. Would need to add the condition <!--[if lte IE 8]>, because browsers like Internet Explorer 9 will apply both filters and RGBa. =.=""
    <!--[if lte IE 8]>
        <style>
            #mainbg1 {
                /* For IE 5.5 - 7*/ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#b2000000, endColorstr=#b2000000);
                /* For IE 8*/
                -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#b2000000, endColorstr=#b2000000)";
            }
        </style>
    <![endif]-->
And here's all the source codes at one glance.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8" >
    <title>Test</title>
    <style type="text/css" media="screen"> 
        body{
            margin: 0px;
			background-color:#00FF00;
		}
        #mainbg {
            width:100%; 
			height:1000px; 
			text-align:center; 
			position:absolute;
        }
        #mainbg1 {
            width:500px;
            height:500px;
            margin: 0px auto;
	
            /* Fallback for web browsers that doesn't support RGBa */
            background: rgb(0, 0, 0) transparent;
            /* RGBa with 0.7 opacity */
            background: rgba(0, 0, 0, 0.7);
        }
    </style>
    <!--[if lte IE 8]>
        <style>
            #mainbg1 {
                /* For IE 5.5 - 7*/ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#b2000000, endColorstr=#b2000000);
                /* For IE 8*/
                -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#b2000000, endColorstr=#b2000000)";
            }
        </style>
    <![endif]-->
</head>
<body>
<div id="mainbg">
    <div id="mainbg1">
    </div>
</div>
</body>
</html>
* Click here for the demo shown in this post.
^ Click here for the source files for the demo.

Friday, June 10, 2011

XML / JSON Reader?

Have you ever encounter the problem of getting a XML file / grabbing a JSON object and you have problem reading the contents? If you have, this is a post for you.


XML
For example, you have a xml file like the following:
How is it possible for a normal user be capable in understanding what information had been stored inside the XML file?

Well, here are a few simple solutions for you.
  1. Get yourself a browser like Mozilla Firefox or Google Chrome.
  2. Drag the XML file into the Mozilla Firefox or Google Chrome browser and voila.
Congratulations. You have got yourself a nicely formatted XML file.

And here are the images for your reference how the XML will look like in a Mozilla Firefox browser and a Google Chrome browser.





Mozilla Firefox Result
Google Chrome Result


JSON
Nowadays for and more API's are using JSON Objects to pass parameters around and Facebook's API would be one of the example of such an API.
Here's an example of how does a Raw JSON object will look like.
Well, here's a simple solution for you people out there.
  1. Get yourself the Mozilla Firefox Browser.
  2. Install this Mozilla Firefox extension known as Firebug.
  3. After all the crazy installation, open up your Mozilla Firefox browser and select 'Option' from the drop-down menu from the top of the browser.
  4. Select 'Firebug' and select 'Open Firebug', when the sub-menu appears.
  5. When the panel for 'Firebug' appears, select the option 'Console' from the top menu of the 'Firebug' panel.
  6. Next copy and paste the raw JSON object next to the '>>>' at the bottom left corner of the panel and press the button 'Enter' from your keyboard.

Congratulations. You should be getting something similar to the following.

Upon clicking on any one of the red/green links, you will be able to see a better view of the contents inside the JSON object, like the following screen grab.

Note: if the panel of 'Firebug' returns a 'SyntaxError: invalid label' error, try adding a '[' add the start of the JSON object and a ']' at the end of the JSON object and try pressiong the button 'Enter' on your keyboard again.

Here's a screen grab for your reference.

I hope that this post will help you to make your life easier in reading XML and JSON object.