Click here to Skip to main content
Click here to Skip to main content

Using Overlay Icon API to Make Client Notifications in IE9

By , 10 Oct 2010
 

Ever wanted to notify your site clients/users while they are surfing in your site. In one of the applications that I helped to build this was a customer requirement. So in the past you could have implemented a blinking behavior that will make the icon of the browser blinking. Not a very user friendly behavior for my taste. With IE9 you now able to use the new SiteMode Overlay Icon javascript behavior which is part of the site pinning feature.

Overlay Icon API

The Overlay Icon API include two simple methods:

  • msSiteModeSetIconOverlay – the method enables to communicate alerts, notifications and statuses to the site users by adding an icon on top of the the existing web site icon. The method takes two parameters – an image url and a tooltip value.
  • msSiteModeClearIconOverlay – the method clears any existing overlay icon.

Pay attention that this behavior will only work in a pinned site so check whether the site is in SiteMode before using these methods.

Overlay Icon In Action

When the following page is loaded in a pinned site the result will be an overlay icon on top of the pinned site icon:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head runat="server">
    <title>My application</title>

    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

    <meta name="application-name" content="My Application" />
    <meta name="msapplication-tooltip" content="My Application" />

    <meta name="msapplication-starturl" content="./" />
    <meta name="msapplication-task" content="name=My Blog;action-uri=http://blogs.microsoft.co.il/blogs/gilf;icon-uri=/favicon.ico" />

    <meta name="msapplication-task" content="name=My Linkedin Profile;action-uri=http://il.linkedin.com/in/gilfink;icon-uri=http://www.linkedin.com/favicon.ico" />
    <script type="text/javascript">

        window.external.msSiteModeSetIconOverlay('/info.ico', 'Attention Needed');
    </script>

</head>
<body>

    <form>
    <div class="page">

        <div class="header">
            <div class="title">

                <h1>
                    My ASP.NET Application

                </h1>
            </div>

            <div class="loginDisplay">
                <asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">

                    <AnonymousTemplate>
                        [ <a href="~/Account/Login.aspx" id="HeadLoginStatus" runat="server">Log In</a>

                        ]
                    </AnonymousTemplate>

                    <LoggedInTemplate>
                        Welcome <span class="bold">

                            <asp:LoginName ID="HeadLoginName" runat="server" />
                        </span>! [

                        <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out"
                            LogoutPageUrl="~/" />

                        ]
                    </LoggedInTemplate>

                </asp:LoginView>
            </div>

            <div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"

                    IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>

                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" />
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" />

                        <asp:MenuItem NavigateUrl="~/IconOverlay.aspx" Text="Icon Overlay" />
                        <asp:MenuItem NavigateUrl="~/msPerformance.aspx" Text="msPerformance" />

                    </Items>
                </asp:Menu>

            </div>
        </div>

        <div class="main">
            <input type="button" value="Remove Icon Overlay" onclick="window.external.msSiteModeClearIconOverlay();" />

        </div>
        <div class="clear">

        </div>
    </div>

    <div class="footer">
    </div>

    </form>
</body>

</html>

The result of running this code can look like:
Icon Overlay Example
The full page can look like:
Icon Overlay
and when pressing the Remove Overlay Icon button it will remove the added information icon.

Summary

IE9 brings a new way to notify users about things that happen in web sites/applications. Using the simple but powerful overlay icon API in pinned sites can make your web site/application more user friendly and more shiny.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Gil Fink
Architect Sela Group
Israel Israel
Member
Gil Fink is an expert in ASP.NET and Microsoft data platform and serves as a Senior Architect at SELA Group. He is a Microsoft data platform MVP and a certified MCPD Enterprise Application Developer. Gil has worked in the past in variety of positions and projects as a leading developer, team leader, consultant and more. His interests include Entity Framework, Enterprise Library, WCF, LINQ, ADO.NET and many other new technologies from Microsoft.
 

My technical blog: http://www.gilfink.net

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130513.1 | Last Updated 11 Oct 2010
Article Copyright 2010 by Gil Fink
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid