Behrooz
Behrooz

Reputation: 2533

Using srcElement in Firefox

I have a problem in Firefox. I can't use window.event.srcElement.id in Firefox and flow code doesn't work in Firefox. Please help me.

$(document).ready(function(e) {
    $("img[rel]").overlay(function() {
        try {
            if (window.event) {
                var sid = window.event.srcElement.id;
                document.getElementById("SelectedNewsID").value = sid;
            }
            else {
                //alert("Error.");
            }
        }
        catch (err) {
            alert("Error");
        }
    });
});

Upvotes: 0

Views: 1280

Answers (2)

ShankarSangoli
ShankarSangoli

Reputation: 69905

Try this

$(document).ready(function(e) {
    $("img[rel]").click(function(e){
       $("#SelectedNewsID").val(e.target.id);
    }).overlay();
});

Upvotes: 0

ShankarSangoli
ShankarSangoli

Reputation: 69905

window.event.srcElement works only in IE. For all other browsers window.event does not work. If you are using JQuery to bind the click event or any other event you will get the event object in which event.target will give you the target element.

Upvotes: 2

Related Questions