one
is NOT what you need as a page refresh will override all the 'memory'.
You are most likely looking for localStorage
or, if you are using internet explorer prior to version 8, use cookies:
<script type="text/javascript">
var alerted = localStorage.getItem('alerted') || '';
if (alerted != 'yes') {
alert("You are using Internet Explorer to view this webpage. Your experience may be subpar while using Internet Explorer; we recommend using an alternative internet browser, such as Chrome or Firefox, to view our website.");
localStorage.setItem('alerted','yes');
}
</script>
EDIT:
For IE versions prior to 8 you need to use cookies, since there is not suppor for localStorage
. It's the exact same concept, just different methods. Take a look at this question for implementing cookies on your page.
After you copied the code from the example, you should have 2 functions - createCookie()
and getCookie()
.
var createCookie = function(name, value, days) {
....
//copy it from the other question
..
}
function getCookie(c_name) {
....
//copy it from the other question
..
}
<!--[if IE]>
<script type="text/javascript">
var alerted = getCookie('alerted') || '';
if (alerted != 'yes') {
alert("You are using Internet Explorer to view this webpage. Your experience may be subpar while using Internet Explorer; we recommend using an alternative internet browser, such as Chrome or Firefox, to view our website.");
createCookie('alerted','yes',365);//cookies expires after 365 days
}
</script>
<![endif]-->
Hope this helps!