Chapter 2. Getting Started with Internet Explorer Mobile

This chapter will be a brief overview of the web development process. It will begin with an overview of web page architecture. It will then discuss best practices for building web pages. Following that we will discuss how this relates to mobile web development. The chapter will finish up with an overview of mobile web development specific to Windows Phone 7.

At the end of the chapter, we will build a very simple web page. We will see how this simple page would be built for a desktop browser and then how we can optimize it for Windows Phone 7's Internet Explorer Mobile browser by crafting the content and adding a single extra CSS file.

This chapter will cover:

  • Web page architecture
  • Internet Explorer Mobile
  • Mobile-friendly META tag settings
  • Building a simple web page enhanced for Internet Explorer Mobile

To get started with Internet Explorer Mobile let's look at basic web page architecture.

Web page architecture

Web pages on the client side mainly consist of three vital components: HTML, CSS, and JavaScript. The exact version of each of these varies, but in the end it all comes down to these three pieces.

HyperText Markup Language (HTML)

HyperText Markup Language (HTML) is the container for the page content. The page should contain just that content and nothing else. A properly coded site would leave the presentation and functionality portions of the page to CSS and JavaScript. In addition, the content should be constructed in a manner that makes logical sense for the content that is being delivered. This is called semantic HTML.

By using semantic HTML, the page content can be readily searchable by a wider range of devices, other than just a desktop browser. Although in this book, we will use this to our advantage to write pages that can be viewed in Windows Phone 7's Internet Explorer Mobile browser, it can also help search engines discover your site content, and assist people with disabilities in getting to your content.

People with disabilities use devices, such as a screen reader, to get the content of a site. These screen readers can only gather information from the actual markup of the site. If we have a PNG image with text in it, the screen reader cannot "see" that information. In that particular case, we can use the alt attribute of the image to provide a hint to the content, but it would be better to put the content inside a paragraph, unordered list, or some other textual tag and then replace it with an image if absolutely required using JavaScript.

The other case that was mentioned earlier was that search engines can better determine the contents of a web page with semantic markup. This will help our page rankings and hopefully drive more visitors to our site.

Think about the HTML markup like the script of a movie. Although we'll add lights, actors, and probably special effects later, right now the black and white text on paper has to convey all of the meaning. The same is true of the HTML markup for your site. As you build websites, constantly keep in mind what information you are trying to impart with the page and make that the focus.

Cascading Style Sheets (CSS)

Cascading Style Sheets (CSS) are documents that describe the way HTML should be displayed. The CSS language allows the web developer to separate the design aspects (layout, colors, fonts, and so on) from the page content. One could easily change the entire look and feel of a page simply by replacing the CSS files. An amazing group of examples of this is available at http://csszengarden.com. The CSS Zen Garden website demonstrates the amazing power that CSS has on the presentation of HTML content. Utilizing a proper style sheet can result in content that will quickly display the relevant information that a Windows Phone 7 user has come to expect from the applications on the phone.

When developing websites that are going to be viewed on Internet Explorer Mobile, it is important to keep in mind some very important potential problems. Although float works great on desktop browsers and will work on many mobile browsers, the content within these containers may not look good on a small screen.

The CSS float attribute was one of the first tools that allowed web developers to break free from table based layouts, that is, laying out the contents of a page using tables. Float allowed developers to group content in div elements and then float those block elements into position. It is a very powerful tool, but on a mobile device, the limited screen size would hamper the ability for the user to view the content. Instead, they would be constantly scrolling left and right or up and down to find all the content.

A better way of handling this would be to utilize float on the desktop version of the site and then leave the div elements in block display allowing the IE Mobile browser to handle the content layout.

Along these same lines, the CSS attributes, padding and margin, work great for precise positioning of elements on a desktop browser. However, the limited screen real-estate of a Mobile browser limits the usefulness of this positioning power. Try to limit the use of these attributes on the mobile device and only use them to highlight useful information.

Finally, because pixels are absolute values, a pixel is a precise defined scale of measurement with no room for interpretation; the phone has to work more to display those elements that are positioned using pixel measurements. Using points, em, or percentage measurements instead, allow the phone to be more fluid with the layout.

Be sure to test the site on Windows Phone 7 devices to ensure the content is legible and the display is fine.

JavaScript

JavaScript, otherwise known as ECMAScript, is the scripting language that is used to create dynamic user interfaces and allow a page to update "on the fly". Users have come to expect a certain fluidity to their web experiences, and now with the power of Internet Explorer Mobile for Windows Phone 7, they can have that same power in the palm of their hand.

Note

Remember that the user is probably looking at a 3.5 inch screen, has fingers that are roughly 40-80 pixels square, and those fingers are incapable of registering a hover command to the browser. If your navigation, for example, requires the user to hover over something, this will not work in Internet Explorer Mobile. Instead, make the navigation an easy to use, unordered list of hyperlinks

Putting HTML, CSS, and JavaScript together

Windows Phone 7 is about getting the relevant information viewable with minimal fuss. The following are some tips for creating a website for Windows Phone 7's Internet Explorer Mobile:

  • Show only the content that is relevant for the page requested
  • Reduce the use of images and colors
  • Remove the extra-large hero images
    • Hero images are those large images usually at the top of the main content section, but usually used as a graphic headline.
    • Usually, they don't contain any content and only serve to enhance the design of the site.
  • Rearrange the navigation to take up a minimum amount of space
  • Move the navigation to the bottom of the page if possible
  • Remove flashy loading screens

Utilizing HTML, CSS, and JavaScript with proper discipline will result in more satisfied customers.

Developing websites is not a trivial task. Mastering each of these three components is a great task. It is important, while developing websites, to try and minimize as much duplication as possible, not only in the JavaScript code that so many developers tended to focus on, but also in the CSS and the HTML content. Reducing duplication will allow for maintainable, upgradable, and understandable code.

Also, by reducing duplication, the amount of data sent to the browser is also reduced. This is helpful when dealing with a browser that is connecting from a patchy cellular network.

Historically, building a mobile version of a website meant a completely different team of designers and web developers built a totally separate web application from the desktop version of the site. Then, using the server side code, the mobile browsers were detected and redirected to the mobile version. SharePoint does this by redirecting mobile browsers to {server}/_layout/mobile/mblwiki.aspx?Url=%2FSitePages%2FHome%2Easpx as an example. This book will utilize the practice of building websites where the exact same site is used for both the desktop and the mobile browsers.

When starting a new web application, a general rule of thumb is to use content adaptation techniques for the application. However, for a baseline you must have at least:

  • ECMAScript 3
  • W3C DOM Level 1
  • W3C standard box model support
  • CSS2 rendering
  • Client-side cookies support
  • XMLHttpRequest object support

By targeting this lowest common denominator of browser, we will ensure that our web applications will run well on most browsers on the web.

Remember that common practices on desktop browsers may end up being annoyances on a mobile device. Try not to open modal dialog boxes, or even open pop-ups. Opening a pop-up window will cause a whole new tab to appear. This may even close a tab that the user had previously opened if they already had six tabs open.

Note

When designing the user interaction for a website, always keep the user in mind. They are busy people coming to your website. Be kind to them. Give them the information they are looking for without hassle.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.62.168