Display IE browser warning pop up using window.sessionStorage

 Step 1: define modal window

<div id="IEUserWarningModal" class="hide">
<div class="por-submit-title">
<span style="float: left; "><theme:image code="img.attention" alt="ATTENTION" title="ATTENTION" /></span>
<div class="attentionLabel" > <spring:theme code="text.attention" text="ATTENTION" /></div>
</div>
<div class="warningMessageContainer" id="warningMessageContainer" >
<spring:theme code="ie.warning.text1" text="Soon you will not be able to run <your website name> with Internet Explorer."/> <br/><br/>
<spring:theme code="ie.warning.text2" text="Microsoft is discontinuing support for the Internet Explorer web browser and obsoleting it. Microsoft is recommending switching to Microsoft Edge."/>
</div>
   <!-- download links to various browsers-->
<div class="buttonContainer" >

<button type="button" class="positive large" onclick="window.open('https://www.microsoft.com/en-us/edge', '_blank');" >
<theme:image code="img.microsoft.edge.logo" alt="Microsoft Edge" title="Microsoft Edge" /><spring:theme code="browser.microsoft.edge" text="Microsoft Edge"/>
</button>&nbsp;<br/><br/>
<button type="button" class="positive large" onclick="window.open('https://www.google.com/chrome/', '_blank');">
<theme:image code="img.chrome.logo" alt="Google Chrome" title="Google Chrome" /><spring:theme code="browser.google.chrome" text="Google Chrome"/>
</button><br/><br/>
<button type="button" class="positive large" onclick="window.open('https://www.mozilla.org/en-US/firefox/new/', '_blank');" >
<theme:image code="img.firefox.logo" alt="Firefox" title="Firefox" /><spring:theme code="browser.firefox" text="Firefox"/>
</button><br/><br/>
<button type="button" class="positive large" onclick="window.open('https://www.apple.com/safari/', '_blank');" >
<theme:image code="img.safari.logo" alt="Safari" title="Safari" /><spring:theme code="browser.safari" text="Safari"/>
</button>
</div>
</div>

Step 2 : Jquery code

//load it on page loading

$(document).ready(function() {
isIEBrowser();
 openIEUserWarningModal();
 });

//check if IE browser
isIEBrowser: function () {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
var trident = ua.indexOf('Trident/');
if(msie > 0 || trident > 0){
return 'Y';
}
}
//modal pop up
openIEUserWarningModal: function () {
var displayIEWarning;
if(window.sessionStorage){
displayIEWarning = sessionStorage.getItem("displayIEUserWarning");
}
if(ACC.common.isIEBrowser() == 'Y' && displayIEWarning != 'N'){
         //open pop up after delay 400 ms after page load
setTimeout(function(){
$("#IEUserWarningModal").dialog("open");
},400);
}
$("#IEUserWarningModal").dialog({
autoOpen: false,
modal: true,
width: 447,
height: 430,
close :function(data){
if(window.sessionStorage){
            //setting in window storage on pop up close
sessionStorage.setItem("displayIEUserWarning", 'N');
}
}
});
},


Comments

Popular posts from this blog

Hybris / SAP Commerce Cloud Groovy Scripting Job to Generate CSV/Excel Reports and copy to Commerce cloud Blob Storage

Emma's dream - a kids story - By Kavya

Hybris/ SAP commerce Cloud: Retry failed/not sent emails due to SMTP connection issue.