I am developing a website and now am testing in all browsers, I am currently testing in firefox and have found and error when using event.sourceElement?
What i need e.srcElement to do is return values, a bit below i show an example on how i get the value PropID returned.
I have written a Jquery function that uses the e.srcElement and it looks as follows:
$(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);
});
});
example of how e.srcElement works:
While testing in chrome and using the inspect element i can find that the following line returns:
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 PropID result needed.
Is there some other why for me to return the values needed? Or How can i get e.srcElement to work in fireFox?
in firefox simply call e.target
to work. instead of e.srcElement
[which works only in IE]
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 e
from:- http://www.quirksmode.org/js/events_properties.html
Simple as
var val= (e.srcElement||e.target).value;
console.log(val);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With