diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html
index 2fb17bb..c493329 100644
a
|
b
|
|
55 | 55 | {% submit_row %} |
56 | 56 | |
57 | 57 | {% if add %} |
58 | | <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script> |
| 58 | <script type="text/javascript"> |
| 59 | try { |
| 60 | document.getElementById("{{ adminform.first_field.auto_id }}").focus() |
| 61 | } catch(TypeError) { |
| 62 | (function(){ |
| 63 | var forms = document.forms || []; |
| 64 | for(var i = 0; i < forms.length; i++){ |
| 65 | for(var j = 0; j < forms[i].length; j++){ |
| 66 | if( |
| 67 | forms[i][j].type != "hidden" |
| 68 | && forms[i][j].disabled != true |
| 69 | && forms[i][j].style.display != 'none' |
| 70 | && forms[i][j].style.visibility != 'hidden' |
| 71 | && forms[i][j].nodeName.toLowerCase() != 'fieldset' |
| 72 | ){ |
| 73 | forms[i][j].focus(); |
| 74 | return; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | })(); |
| 79 | } |
| 80 | </script> |
59 | 81 | {% endif %} |
60 | 82 | |
61 | 83 | {# JavaScript for prepopulated fields #} |