For security reasons you can't trigger the dialog, unless it is as a response to some user triggered event. You could for instance trigger the dialog through a click on some other element:
$(function () {
$(".someElement").click(function () {
$('#f').click();
});
});
Working example.