I\'m creating a button dynamically using JavaScript and at the same time assigning attributes such as \'ID\', \'type\' etc and also \'onclick\' in order to trigger a functio
You have to assign a function, not a string.
backButton.onclick = function wastefulDuplicationOfBackButton () { navigate(-1); }