Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'Capture'
javascript, jquery, jquery-events, jquery-ui
Solution
`/assets/Capture.PNG` is interpreted as a regex literal (for `assets`) with `Capture.PNG` as flags - which are invalid. You wanted a string: `'/assets/Capture.PNG'`.
Anyway, you shouldn't use inline event handler attributes - especially when you already have jQuery available. Better:
$("#test_point_geck_info").html('<div id="img_1" class="img_1">' +
'<img src = " + ROOT_PATH + "/assets/Capture.PNG" title="xyz" ' +
'class="thumbnail" width="100" height="100"></div>').find("img").click(PopImage);
function PopImage(e) {
var imagesrc = this.src,
caption = this.title;
var PopupImageContainer = new Image();
PopupImageContainer.src = PopupImageSRC;
PopupImageContainer.onload = function() {
PopupImageDisplay(PopupImageContainer, PopupImageCaption, PopupImageSRC);
};
}
.thumbnail {
cursor: pointer;
}
Problem
``` $("#test_point_geck_info") .html("<div id='img_1' class='img_1'>" + "<img src = " + ROOT_PATH + "/assets/Capture.PNG onclick=PopImage(" + ROOT_PATH + "/assets/Capture.PNG,'xyz')" + " style='cursor:pointer;' class=thumbnail width='100' height='100'></div>"); ``` Results following on the browser: ``` <img src="/assets/Capture.PNG" onclick="PopImage(/assets/Capture.PNG,'xyz')" style="cursor:pointer;" class="thumbnail" width="100" height="100"> ``` function that am calling : ``` function PopImage(imagesrc,caption) { var PopupImageContainer = new Image(); PopupImageContainer.src = PopupImageSRC; setTimeout("PopupImageDisplay()",loadDelay); } ```