0

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?

Sabeen Malik
  • 10,816
  • 4
  • 33
  • 50
  • The Javascript per-se seems to be alright. Could you do some tests on these users' machines using Firebug or similar? – artagnon Sep 23 '09 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. – Sabeen Malik Sep 23 '09 at 13:10
  • Which version of Safari and FF? – James Black Sep 23 '09 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. – Sabeen Malik Sep 23 '09 at 17:46

3 Answers3

1

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.

Krishna Kant Sharma
  • 1,567
  • 1
  • 12
  • 18
0

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.

Community
  • 1
  • 1
orip
  • 73,323
  • 21
  • 116
  • 148
0

This could be related to these Chrome and Safari bugs where FORM with target="_blank" does not always work as expected.

kangax
  • 38,898
  • 13
  • 99
  • 135
  • thats the interesting bit here.. it doesnt work with Safari and Firefox on MAC. and the other user says it gives him blank page on clicking preview in IE8 .. interestingly all of them report that the new window/tab does open .. so _blank seems to work ok. – Sabeen Malik Sep 23 '09 at 13:14
  • But the ticket mentions that form is **only submitted once**. Could that be the problem? – kangax Sep 23 '09 at 13:16
  • nah .. u can click on preview and that would open a new window and then once ur satisfied with how ur content looks after several previews u can click save – Sabeen Malik Sep 23 '09 at 16:06