One thing that I have done in the past is to simply use the “data” that is commonly used in slide shows, etc. But write down the data you need in the same way as in the attribute "style".
<div class="your_element" data="onselectstart:foo;oncontextmenu:bar;">
</div>
Then use jquery to capture the data:
var onSelectStart = getData($(".your_element"), "onselectstart");
Function:
function getData(elementObject, indexString)
{
var dataElements = elementObject.attr("data").trim().split(";");
var result = dataElements.some(function(entry) {
dataArray = entry.trim().split(":");
if(dataArray[0] == indexString)
{
found = dataArray[1].trim();
return true;
}
});
return result ? found : false;
}
Not really the end of the world, as several others have mentioned. As I said, "data" is usually used and even highlighted as valid in some IDEs.
source
share