function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nagesh ENagesh E 

trying to add little JavaScript to my standard edit page using S-controll

 

<script type="text/javascript">
{
window.parent.location.href="/{!Contact.Id}/e?retURL=%2F{!Contact.Id}";

if (document.getElementById('name_lastcon2').value == 'Dummy 123')
{
document.getElementById('name_lastcon2').value = '';
}
}

</script>

 

This one is going into infinate loop.. i didnot see anything on the page

Kris GrayKris Gray

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?

sfdcfoxsfdcfox

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.