File partial.html looks like this:
Partial.html is dynamically included on
Events like click bubble, so you attach the event handler to the closest non-dynamic parent, and inside the event handler you check if it was the button being clicked by seeing if it was the event's target :
var parent = document.getElementById('pageArea');
if (parent.addEventListener) {
parent.addEventListener('click', handler, false);
}else if (parent.attachEvent) {
parent.attachEvent('onclick', handler);
}
function handler(e) {
if (e.target.id == 'test') {
// the button was clicked
}
}
FIDDLE