Want to send a status value to contentscript.js in chrome extension from the page in the browser, doing it by adding a value to newly created event passing it to extension, but but receiving the value as 'undefined'. code as follows.
page.html
<html>
<head></head>
<body>
<script>
var go = function() {
var sam=1;
var event = document.createEvent('Event',{"details": 1});
event.foo=sam;
event.initEvent('hello');
document.dispatchEvent(event);
}
</script>
<a href="javascript:go();">Click me</a>
</body>
</html>
I am trying to access the value of 'foo' and 'status'(either of this ), but getting both values as 'undefined'.
contentscript.js
document.addEventListener("hello", function(data) {
alert("test:foo "+data.foo+":"+data.status);
})
please let me know how to access the value.