E.srcElement - undefined in firefox?

I am developing a website and now testing in all browsers, currently testing in firefox and found an error when using event.sourceElement?

I need e.srcElement to do this return value, just below, I am showing an example of how I get the return value of PropID.

I wrote a jQuery function that uses e.srcElement, and looks like this:

$(function () { $(".DownloadLink").click(function (e) { e.preventDefault(); var PropID = getParameterByName("PropID", e.srcElement.search), Token = getParameterByName("Token", e.srcElement.search), TrackingNumber = getParameterByName("TrackingNumber", e.srcElement.search); $.post("Valuation", { PropID: PropID, Token: Token, TrackingNumber: TrackingNumber}, function (taskId) { // Init monitors $("#dialog-modal").append($("<p id='" + taskId + "'/>")); updateMonitor(taskId, "Started"); // Periodically update Modal var intervalId = setInterval(function () { $.post("Progress", { id: taskId }, function (progress) { if (progress < 50) { updateMonitor(taskId, "Building File"); } else if (progress == 50) { updateMonitor(taskId, "Uploading File to FormMobi"); } else if (progress >= 100) { clearInterval(intervalId); updateMonitor(taskId, "Complete"); window.location.href = "downloadcomplete"; } }); }, 100); }); }); 

e.srcElement work example:

When testing in chrome and using a validation element, I can find that the following line is returned:

Line of code:

PropID = getParameterByName ("PropID", e.srcElement.search)

Returned result:

Search: "PropID = 77301 &? Token = 74d30c0e-b4ab-4164-9dfd-f35fd7091cdc & Trackingnumber = 367"

And so I can get the result of PropID.


Are there any other reasons why I need to return the values ​​I need? Or How can I get e.srcElement to work in fireFox?

+6
source share
3 answers

in firefox just call e.target to work. instead of e.srcElement [which only works in IE]

+19
source
 function getTarget(obj) { var targ; var e=obj; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; if (targ.nodeType == 3) // defeat Safari bug targ = targ.parentNode; return targ; } 

Will return the target for all browsers if you pass it to e

from: - http://www.quirksmode.org/js/events_properties.html

+7
source

Just like

 var val= (e.srcElement||e.target).value; console.log(val); 
+1
source

All Articles