Easy way to add “Privacy Policy” to Windows Charm settings – Using HTML/JavaScript


After reading the “Easy way to add “Privacy Policy” to Windows Charm settings – Using C#/XAML” many people asked me how to do the same thing in a HTML/JavaScript Windows Store app. well its kind of easily compared to C#/XAML. given below are the steps for that,

1.Create HTML page

it is necessary to have an separate HTML page inside the windows store app for privacy policy.after that add the following code to the body of that page.

<div id="privacy" data-win-control="WinJS.UI.SettingsFlyout" aria-label="Help settings flyout"
data-win-options="{width:'wide'}">
<div class="win-header" style="background-color:#000000;color:#FFFFFF">
<button type="button" onclick="WinJS.UI.SettingsFlyout.show()" class="win-backbutton"></button>
<div class="win-label">Privacy Policy</div>
</div>
<div class="win-content">
<p>The application does not collect any personal data of users and is for the sole purpose of delivering the requested information to the users. </p>
</div>
</div>

2. Link with JavaScript file

Inside the “default.js” there will be “app.onactivated” function, add the following code to the IF part in the IF ELSE condition.

WinJS.Application.onsettings = function (e) {
e.detail.applicationcommands = {
"privacy": { href: "PP.html", title: "Privacy Policy" }
};
WinJS.UI.SettingsFlyout.populateSettings(e);
}
WinJS.Application.start();

Things to remember in this is the privacy policy html page must be correctly linked and the DIV tag which has

data-win-control="WinJS.UI.SettingsFlyout"

must be properly called in the JavaScript function.

Now debug and check, you can see your privacy policy in the Windows Charm settings 🙂

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s