Using Overlay Icon API to Make Client Notifications in IE9
Join the DZone community and get the full member experience.
Join For Free
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:
the full page can look like:
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.
Published at DZone with permission of Gil Fink, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments