Posts Tagged ‘pinned site’

How to Pin a Website And Why to Pin a Website

I was just preparing a slide deck to talk about IE9 features at the Microsoft Certified Trainer summit and realized, that although I have blogged about how to update your pinned sites, I really haven’t taken the time to explain what the heck pinned sites are and how they work. Pinned sites are a fantastic feature of IE9, and as more and more users are discovering them, you want to make sure your website makes the most of this feature.

Before I get into the technical aspect, let me take a moment to tell you why you want your web site to support pinning. Users who pin your site will visit your site more often, and will spend more time on your site. In the words of Martha Stewart “That’s a good thing”. Whether its an internal company website you want your users to access easily, or a public site you use to help your business or group we build the site because we want users to spend time there. So if pinning increases the amount of time users spend there, you want pinning.

If you are using IE9 or higher you can quickly try out pinning right now to see how it works. Open a tab in your browser and visit tsn. Now drag the tab down to your taskbar. You will see a TSN icon appear on your taskbar and you will also notice the TSN website now looks different, the forward and back buttons appear in red to match the logo. The icons on your page have changed from the IE logo to the TSN logo. The icon you see is called a favicon, and you can set the of the forward and back buttons based off the favicon or by specifying specific colors.

TSNfaviconzoomin

Now let’s take a closer look at that logo you just added to the task bar.  You can close the IE windows with TSN and relaunch the site by clicking on that icon. That’s nice, basically just like you can have icons for launching your desktop applications, you now have an icon to launch a web site. Here’s the really cool part, you can also right click on the icon to go directly to a particular part of the website like the News or TV Schedule. It’s like Browser Favorites but wayyyyy better!

TSNJumpListZoomedin

Nice Eh? And it’s really easy to do. Since its implemented with metatags, you can add the functionality for your users who have IE9 without breaking the website for users on other browsers. You can make your pinned site as simple or as fancy you want, it’s just a matter of how much time you want to spend, 10 minutes to set up a favicon? an hour or a day to add more functionality.

You can just add a favicon, quick and easy!

You can add a jumplist to the pinned site just like TSN did, to make it easier for users to navigate the site using a few metatags or JavaScript.

You can get fancy with thumbnail buttons, and notifications by adding a little more JavaScript.

Read on to find out how!

1. Create a favicon

If you are a talented graphic artist, or have someone on your team who knows how to make .ico files good on you! For the rest of us check out xiconeditor.com. You can import a .JPG, .GIF, .BMP, .PNG, or .ICO file, crop it and xiconeditor will generate a .ico file suitable for pinned sites. That was easy Smile

2. Add the favicon to your HTML in the <head> section.

<link rel="shortcut icon" href="favicon.ico"/>

Now you will see your favicon appear in the browser and on the toolbar if you pin your site. Next you should set up your meta data for the pinned site in the <head> section

  • application-name specifies the name of your pinned application, give it a meaningful name.
  • msapplication-tooltip specifies what will be displayed when you hover over the pinned application in the start menu (not the taskbar)
  • msapplication-starturl specifies the URL to be launched when the pinned website is launched
  • msapplication-window tells IE9 how big to make the browser when it launches the pinned application
  • msapplication-navbutton-color tells IE9 what color to use for your navigation buttons, if you omit this tag, IE9 will take the color from your favicon. Specify any hex color or CSS3 color name.
<meta name="application-name" content="My Pinned Content" />
<meta name="msapplication-tooltip" content="Launch My pinned site" />
<meta name="msapplication-starturl" content="http://localhost:42942/PinnedSites/index.html"/>
<meta name="msapplication-window" content="width=1024;height=768" />
<meta name="msapplication-navbutton-color" content="#FF3300" />

3. Add a Static Jump List

The Jump List is the context menu that appears when you right click on the pinned site icon on your taskbar. To add a task to the jump list, you need to add a meta tag for msapplication-task. You can add up to 5 static tasks to the jump list. The tasks in the jump list will appear in the same order as you define the tasks in the HTML.

Msapplication-task indicates this is a task you want to add, in the content attribute you specify

  • name – this is the text that will be displayed in the jump list
  • action-uri this is the URL to open if someone selects this task from the jump list
  • icon-uri specifies the icon to display in the jump list for this task.
  • window-type (optional) specifies if the destination should be opened in a tab (default), self (the current tab) or window (a new pinned site window)
<meta name="msapplication-task" content="name=View Pictures; action-uri=http://localhost:42942/PinnedSites/pictures.html; icon-uri=favicon.ico" />

4. Add a Dynamic Jump List (if you want to)

Use JavaScript to create tasks dynamically on a jumplist, you do not have the 5 task limit with dynamic jump lists. Creating dynamic tasks requires using the following methods

  • window.external.msSiteModeCreateJumpList() to create the dynamic jump list
  • window.external.MsSiteModeAddJumpListItem() to add a task to the dynamic jump list
  • window.external.msSiteModeShowJumpList() to display the jump list
function AddJumpList()
{
    if (window.external.msIsSiteMode())
    {
         window.external.msSiteModeCreateJumplist("My Dynamic List");
         window.external.msSiteModeAddJumpListItem("Added with code","http://www.tsn.ca/","favicon.ico");
         window.external.msSiteModeShowJumplist();
     }
}

So with a few meta tags you can set up your website as a pinned site, with a little JavaScript you can even have a dynamic jump list. If you want to update the jumplists later, no problem! In fact I wrote some blogs explaining How to update a static jumplist, and how to update a dynamic jump list

5. Go all out and add a thumbnail toolbar (if you want to)

If your website plays video or audio, or you have other actions you want users to control from their pinned site, in addition to the jump lists you can use JavaScript to add a toolbar of thumbnail buttons! Use it to advance slides, pause and play a video or song. This will actually take a bit more time and work, but it’s pretty cool!

Use window.external.msSiteModeAddThumbBarButton to add a 16X16 icon to the thumbnail toolbar

Use window.external.msSiteModeShowThumbBar to display the thumbnail toolbar

  • Create icons for each button you want on the toolbar
  • Add each button to the thumbnail toolbar
  • Define the action you want for each thumbnail toolbar

You cannot add buttons to a toolbar after the toolbar is visible! (You can hide or disable buttons, but you can’t add or remove them)

Thumbnail toolbars can hold a maximum of 7 buttons. You can sometimes use one button as a toggle switch between modes e.g. Play and Pause can be one button instead of making a Play and a Stop button

For example to add a button

var btnRed = window.external.msSiteModeAddThumbBarButton('red.ico', 'Red');
var btnBlue = window.external.msSiteModeAddThumbBarButton('blue.ico', 'Blue');
window.external.msSiteModeShowThumbBar();
document.addEventListener('msthumbnailclick', onButtonClicked, false);

Then add a line of code to display the toolbar

window.external.msSiteModeShowThumbBar();

Create event handlers for the thumbnail toobar to define the actions to take when a button is pressed (As an added bonus if you are using IE9 you can use AddEventListener instead of attachEvent).

document.addEventListener('msthumbnailclick', onThumbnailButtonClicked, false);

function onThumbnailButtonClicked(btn) {
          switch (btn.buttonID) {
              case btnRed:
                  document.bgColor = '#990000';
                  break;
              case btnBlue:
                  document.bgColor = '#000099';
                  break;
          }
      }

If you want to have a toggle button, for example a play/pause button, on your toolbar, you use window.external.msSiteModeAddButtonStyle to define a style with an alternative icon image and tooltip for a specified button and use window.external.msSiteModeShowButtonStyle to change the icon image and tooltip for the button in your event handler.

styleColored = 0;  //default style ID, this style was created when you added the button
styleClear = window.external.msSiteModeAddButtonStyle(btnRed, 'white.ico', "Clear");
function onThumbnailButtonClicked(btn) {
          switch (btn.buttonID) {
             case btnRed:
             if (document.bgColor != '#990000')
                 {
                  document.bgColor = '#990000';
                  window.external.msSiteModeShowButtonStyle(btnRed, styleClear);
                  break;
                  }
            else {
                  document.bgColor = '#FFFFFF';
                  window.external.msSiteModeShowButtonStyle(btnRed, styleColored);
                  break;
                  }
              case btnBlue:
                  document.bgColor = '#000099';
                  break;
          }
      }

So did you get all that? Don’t worry you don’t have to do everything! I just wanted you to know all your options. Any site can be pinned. If you add a favicon, you make your site look better when its pinned. When you add a jumplist you make it easier for a user to navigate to specific regions in your site. You decide how much functionality makes sense! For more information about pinned sites check out BuildMyPinnedSite.com which has more great information including how to add notifications (those tiny icon overlays, like one in Windows Messenger that shows you if you are signed in), suggestions on how to help users learn how to pin your site, and how to measure the success of your pinned site! Download IE9 and start pinning your site today!

This blog is also posted on the Developer Connection

Advertisements

How do you update a Pinned Site in IE9? Part 2

Pinned sites are such a cool feature, easy to implement, and they give a great themed look and feel to your website in IE9. But as soon as we implement a feature for a user, the user changes their mind or adds a new requirement. A while ago I wrote a blog describing how to update the static jump list for a pinned site. Today I’d like to show you how to update the dynamic jump list for a pinned site.

Quick aside, if you aren’t familiar with pinned sites, go to a site which implements pinning such as imdb.com, tsn.ca, or theweathernetwork.ca and drag the tab down to your taskbar to check it out. For instructions on how to pin your own site check out BuildMyPinnedSite.com. It really is easy and looks great!

The static jump list implemented with metadata is limited to 5 items and is hard coded in the HTML. A dynamic jump list can contain more than 5 entries and can be generated dynamically. For example, on my team hockey site I want to be able to quickly jump to see information on upcoming games. I would probably read this information from a database or file, but for the purposes of illustration I am simply hardcoding the values to display in my dynamic jumplist.

if (window.external.msIsSiteMode()) { 
    window.external.msSiteModeCreateJumplist("Upcoming Games");
    window.external.msSiteModeAddJumpListItem("Jan 3 vs IceMonsters", "./games.html?gameid=6", "./favicon.ico","tab");
    window.external.msSiteModeShowJumplist();
}

This code creates a menu category called Upcoming Games and displays one item in the dynamic jump list that will open a new tab with information about the upcoming game against the Ice Monsters.

DynamicJumpListStartZoomedIn

Maybe another game against the Puck Hogs is added to the schedule. So I update my code to add another item to the jump list.

if (window.external.msIsSiteMode()) {
    window.external.msSiteModeCreateJumplist("Upcoming Games");
    window.external.msSiteModeAddJumpListItem("Jan 3 vs IceMonsters", "./games.html?gameid=6", "./favicon.ico", "tab");
    window.external.msSiteModeAddJumpListItem("Jan 11 vs PuckHogs", "./games.html?gameid=7", "./favicon.ico", "tab");
    window.external.msSiteModeShowJumplist();
}

Of course there are lots of team members who have already pinned the site to their desktop. The next time they launch the site, they see the following list.

DynamicJumpListMultipleEntriesZoomedIn

Whoops! That is not what I was after! When the users who have already pinned my site launch my updated site, the original jump list item is still there and my code to define the jump list re-runs, the end result is not only do I get my new item added but the original item is added a second time! This is why it is important to include a call to the msSiteModeClearJumpList() method before you populate your dynamic jump list. This will reset your dynamic jump lists for anyone who has already pinned your site.

if (window.external.msIsSiteMode()) {
           
window.external.msSiteModeClearJumplist();
            window.external.msSiteModeCreateJumplist("Upcoming Games");
            window.external.msSiteModeAddJumpListItem("Jan 3 vs IceMonsters", "./games.html?gameid=6", "./favicon.ico", "tab");
            window.external.msSiteModeAddJumpListItem("Jan 11 vs PuckHogs", "./games.html?gameid=7", "./favicon.ico", "tab");
            window.external.msSiteModeShowJumplist();
        }

Now when my hockey team goes back to the site they see my updated jump list displayed correctly.

DynamicJumpListUpdatedCorrectlyZoomedIn

So now you cannot only pin your site with static and dynamic jump lists, you can update them as needed and be confident that even users who have already pinned your site will pick up the changes correctly.

Today’s My 5

5 Steps to create a Favicon for your site (The favicon is that little picture that appears as the icon when you pin your site, and in the search bar and tab when you are browsing the site)

  1. Find a JPG or GIF file that contains an image you think will look good as an icon.
  2. Visit the x-icon editor website.
  3. Import your image, crop it and then export your image into a .ico file.
  4. Copy the favicon.ico file to a directory that can be accessed by your web site.
  5. Add the following line of code to the HTML of your web page <link rel="shortcut icon" href="favicon.ico"/>to associate the favicon with your web page.

For more detailed instructions visit BuildMyPinnedSite.com and check out the section “Create a hi-res favicon”

This post is also posted on the Canadian Developer Connection

How do you update a Pinned Site in IE9? (The One Constant in Code is Change!)

I love pinned sites in IE9, they really are cool, and they are good business. At the last IE9 code camp, I was asked “If someone has pinned your site to their taskbar, how can you update the pinned functionality?” Great question! I did a little digging and wanted to share what I found out. Since there are different aspects of the pinned site to update, I will break this up into a series.

Quick aside, if you aren’t familiar with pinned sites, go to a site which implements pinning such as cbc.ca, globeandmail.ca, or RottenTomatoes.com and drag the tab down to your taskbar to check it out. For instructions on how to pin your own site check out BuildMyPinnedSite.com.

Part 1 – Updating Your Static Jump List

Let’s start with a pinned site that has a static jump list users can launch to navigate to different parts of the website. My website is called Hockey Mom, and I use it to keep track of my son’s endless series of hockey practices and games! I have set it up as a pinned site with a jump list that allows me to go straight to the schedule or to maps of all the different hockey arenas.

I have two meta tags that define the static jump list.

<meta name="msapplication-task" content="name=Schedule;action-uri=./schedule.html;icon-uri=./favicon.ico" />
<meta name="msapplication-task" content="name=Arenas;action-uri=./ArenaMaps.html;icon-uri=./favicon.ico" />

In my meta data I specify two elements with a name of msapplication-task. Each defines one menu item in my jump list. The name attribute determines the text that appears in the jump list, the action-uri determines the URL to navigate to if that item is selected, and the icon-uri determines the icon to display beside the text in the jump list.

When I pin my site and display the jump list, it looks like this:

JumpListVersion1Cropped

A few weeks into the season, my son keeps asking me to check how his team is doing in the standings. So I decide to add Standings to my static jump list.

I update my meta tags and add the new item to my static jump list

<meta name="msapplication-task" content="name=Schedule;action-uri=./schedule.html;icon-uri=./favicon.ico" />
<meta name="msapplication-task" content="name=Arenas;action-uri=./ArenaMaps.html;icon-uri=./favicon.ico" />
<meta name="msapplication-task" content="name=Standings;action-uri=./Standings.html;icon-uri=./favicon.ico" />

I build and deploy the new website. If I right click my pinned site icon, it has no idea that the website has defined new items for the jump list and I still see the old jump list appear. So that brings us to the million dollar question how does someone who has already pinned your site, pick up your new jump list?

It turns out the next time I launch the site from my pinned site icon, the changes will be picked up.

JumpListVersion2Cropped

So after you have launched the updated site from your pinned site icon, you will see the updated Static Jump List. No Muss No Fuss. I know anticlimactic wasn’t it? But when you are trying to send out updates for your code, isn’t that a good thing? Next week we’ll look at how to update the dynamic jump list (there is a little twist to dynamic jump lists)

Today’s My 5:

5 Features You Can Add to a Pinned Site.

You can find instructions and code examples for all of these features at BuildMyPinnedSite.com

1. Favicon -  Highlight your site logo! Why display an Internet Explorer logo when you can highlight your brand!

2. Static Jump List – Why limit users to starting at the home page, let them jump straight into the site

3. Dynamic Jump List – Increase the users choices with a dynamic jump list that can change based on what parts of the site you want to highlight week to week.

4: Thumbnail Preview Controls – Make your website feel even more like a native applicaiton by giving the user the ability to perform actions on the site directly from the pinned icon using thumbnail controls.

5: Notifications – Use overlay icons to notify a user when there is no content on your site.

This blog is also posted on Canadian Developer Connection