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?
-
The Javascript per-se seems to be alright. Could you do some tests on these users' machines using Firebug or similar?artagnon– artagnon2009年09月23日 12:14:21 +00:00Commented Sep 23, 2009 at 12:14
-
thats the problem , those 2 ppl are site users , living god knows where and would be hard to get them to agree on giving us access to their screen.SMa– SMa2009年09月23日 13:10:46 +00:00Commented Sep 23, 2009 at 13:10
-
Which version of Safari and FF?James Black– James Black2009年09月23日 17:23:14 +00:00Commented Sep 23, 2009 at 17:23
-
FF is definitely latest , cause the user downloaded it when we requested them to , not sure about Safari , i am guessing it would be the latest too.SMa– SMa2009年09月23日 17:46:32 +00:00Commented Sep 23, 2009 at 17:46
3 Answers 3
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.
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.
1 Comment
This could be related to these Chrome and Safari bugs where FORM with target="_blank" does not always work as expected.