You should check to see if window.parent.location equals window.location (or window.parent equals window). Otherwise you will will indeed enter an infinite loop, since you are instructing the browser to refresh the page, which instructs the browser to refresh the page, ad infinitum...
Next, you need to check to see if you're on a contact edit page, and that the field is visible; use document.getElementById, and make sure the result is not null.
window is considered the top level, and so window.parent is just window.
Then when you assign to location.href your just redirecting to a new page, which I assume is the page your on.
What were you attempting to do?
You should check to see if window.parent.location equals window.location (or window.parent equals window). Otherwise you will will indeed enter an infinite loop, since you are instructing the browser to refresh the page, which instructs the browser to refresh the page, ad infinitum...
Next, you need to check to see if you're on a contact edit page, and that the field is visible; use document.getElementById, and make sure the result is not null.