javascript - To create clickable canvas using MSPointerEvent for IE 11 -
i have been trying make clickable canvas on ie 11. if click on canvas, it'll open url in next window. problem originated after reading documentation of ie 11. "mouseevent" changed "mspointertype". did try write .initpointerevent
it's still not working. here non-functioning code.
</head> <body> <script type="text/javascript"> var canvas = document.createelement('canvas'); canvas.id = "dgmobix-poplayer"; var body = document.getelementsbytagname("body")[0]; canvas.width = body.clientwidth; canvas.height = body.clientheight; canvas.addeventlistener('click', function(event) { var t = document.createelement("a"); t.href = "http://www.google.com"; t.target="_blank"; var n = document.createevent("mspointerevent"); n.initpointerevent("click", true, true, window, 0,`` 0, 0, 0, 0, true, false, false, true, 0, null,0,0,0,0,0,0,0,0,1,2,0,true); t.dispatchevent(n,true) ; this.parentnode.removechild(this); },false); body.appendchild(canvas); </script><canvas id="dgmobix-poplayer" width="1366" height="646"></canvas> </body></html>
before mentions .addeventlistener problem, according ie11 documentation have removed .attachevent (this works on ie10 or below), have adopted w3c method.
Comments
Post a Comment