We have a piece of javascript injected onto a page that was responsible for a redirect, after a redesign of the page and the master page the javascript no longer works.
The Javascript is exactly as below
function PostVspForm()
{{
var vspForm = document.forms['vsp'];
if (!vspForm) vspForm = document.vsp;
if (!vspForm.onsubmit || (vspForm.onsubmit() != false))
{{
vspForm.action = '{0}';
vspForm.submit();
}}
}}
PostVspForm();
I’m not confident what it does or how to correct it, bearing in mind it also needs to work as above as well.
I believe it’s simply identifying a form called vsp, this form is still on the page but now after calling document.vsp the object is null.
Have you changed the location of this code relative to the vsp form that it is targetting? If so, you may be running it before the form exists in the page.
Try moving your js to the bottom of the page, or wrap it in a block like this:
If you are using jQuery, you can do this:
Hope that helps!