Insert the code at the bottom of your page or in your subsequent JS library.
<script>
$(document).ready( function() {
/* fade them out */
var objs = $('.successmsgdiv,.errormsgdiv');
if (objs.css('display','block')) { objs.delay(2500).fadeOut('slow');}
/* remove the query string from the URL */
var href = window.location.href;
if(href.indexOf('&smsg=')) {
var url = href.split('&smsg='); history.pushState(null,null, url[0]);
} else if(href.indexOf('&emsg=')) {
var url = href.split('&emsg='); history.pushState(null,null, url[0]);
}
});
</script>