If you want to do two things per click event. The function does both of these things and fires when the button is pressed.
window.onload = function(){
var button = document.getElementsByName("B1")[0]
var iframe = document.getElementsByName("IFrameName1")[0]
button.addEventListener('click',addSandboxAndChangeLocation,false);
function addSandboxAndChangeLocation(){
frames['IFrameName1'].location.href='https://www.google.com/';
iframe.sandbox = 'allow-forms allow-scripts allow-same-origin';
}
}
Check it out on jsFiddle !
source
share