See example of the following →
Although I believe this method is not recommended, this is what I developed to test Chrome, FF, Safari, and IE8.
First, I selected the list-style-image property, which will be used to store metadata, since it can contain any string in the url() parameter and still will not be used under any normal circumstances in the CSS body.
Then I applied a generic cross-browser function to getComputedStyle , since it is not available in all browsers.
Then I analyzed the return property to get only data in url('') , as a result we get the following functions:
var getStyle = function(el, cssprop) { if (el.currentStyle) { return el.currentStyle[cssprop]; } else if (document.defaultView && document.defaultView.getComputedStyle) { return document.defaultView.getComputedStyle(el, "")[cssprop]; } else { return (el.style) ? el.style[cssprop] : 0; } }; var pullCSSMeta = function() { var aMeta = getStyle(document.body, 'listStyleImage').split('/'), meta = aMeta[aMeta.length - 1]; return decodeURIComponent(meta.substr(0, meta.length - 1).replace(/"$/,'')); };
If you need to store more than one piece of information, you can tarnish the data or potentially even save a JSON string. I hope you have a good reason for wanting to do this, as I think there are better ways to store metadata ... but there you go!
See example →
mVChr
source share