Reputation: 10880
There is one form i have and a user can click on preview button or save button , both buttons send data to different locations.
Here is the relevant code:
prevAction = location.href;
document.getElementById('preview').value='true';
document.getElementById('form1').target='_blank';
document.getElementById('form1').action = 'http://www.xxx.com/do/preview';
document.getElementById('form1').submit();
document.getElementById('form1').target='';
document.getElementById('preview').value='';
document.getElementById('form1').action = prevAction;
Now it works fine with 99.9% users , however only 2 users have complained so far that it doesn't work for them. One of them is using mac and says it doesnt work in safari and firefox both. When he hits preview , the form data doesn't seem to be post and after hitting preview if they hit save , the form data doesnt go thru as well.Can you guys tell me what i am doing wrong here.
Also one thing which might be relevant .. i mootools is loaded in the head section but this piece of code doesnt make use of it.. can this have an effect?
Upvotes: 0
Views: 792
Reputation: 1587
If submit url and preview url are both in same javascript security sandbox. Then in case of preview: instead of submiting a form, you can just open a new window. And then access data from this window, in a new window, to show your preview.
EDIT
Your real problem is that browser is not accepting 'target' attribute for 'form' tag. It is a deprecated attribute. Which is only available in TF (Transitional & Frameset) DTD. But it is not available in Strict DTD.
You can do things: Change your DTD to TF and hope for the best.
OR: You can implement the above stated solution.
Upvotes: 1
Reputation: 39168
This could be related to these Chrome and Safari bugs where FORM with target="_blank"
does not always work as expected.
Upvotes: 0
Reputation: 75427
Just in case there's a hidden error in that user's environment, you could add an onerror
handler that catches errors and logs them via AJAX to find out. See this question for sample code.
This isn't supported by Safari, but supported by Firefox.
Upvotes: 0