Your syntax is invalid, and targ will always be undefined (even the setting of it will cause an error except in IE).
Code:
<script type="text/javascript">
function setCurrentForm() {
document.getElementById("currentFormName").firstChild.nodeValue = (this.form.name || this.form.id);
}
onload = function() {
for(var i = 0, f = document.forms; i < f.length; ++i)
for(var j = 0, e = f[i].elements; j < e.length; ++j)
e[j].onfocus = setCurrentForm();
};
</script>
</head>
<body>
<p id="currentFormName"> </p>
Bookmarks