user3745870 user3745870 - 1 year ago 191
Javascript Question

onClick not working with single click in IE 11

I am trying to play/pause the video when a user clicks anywhere on the video. The problem is that it is working on the double click in IE 11 and for all the other browsers, it is working perfectly with single left click. Following is my code.

var obj = "<object id=\"video\" onClick=\"clicked('video')\" data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"" + width1 + "%\" height=\"" + height1 + "%\">" +
"<param name=\"onLoad\" value=\"pluginLoad\" />" +
"<param name=\"source\" value=\"player.xap\"/>" +
"<param name=\"initParams\" value=\"sourceurl=" + url + "\" />" +

videoClicked method is as follows"

function clicked(ID) {
$("video").css("cursor", "pointer");
var mediaElementName = "mediaPlayer";
var host = document.getElementById(ID);
var s = host.content.findName(mediaElementName).CurrentState;
if (s == "Paused")

I want it to work with a single left click. When I am using onmousedown, it is working perfectly on IE 11 as well. Can anyone tell me what is wrong with my code?



You shouldn't want to attach the handlers in html, or by yourself. You'll get into loads of these cross browser issues.

Try this:

$("#video").mouseup(function(e) {
    if (e.which != 1) return false;    // Stops all non-left-clicks