Problems with dropdown calendar in Safari

Problems with dropdown calendar in Safari

I have been using a jquery work around for a datepicker which until today has been working perfectly. Suddenly, it has stopped functioning, so that the drop down calendar no longer appears. The code that I have used for the date picker is as follows:

  • <script type="text/javascript">
    1.     var datefield=document.createElement("input");
    2.     datefield.setAttribute("type", "date");

    3.     if (datefield.type!="date"){ //if browser doesn't support input type="date", load files for jQuery UI Date Picker
    4.         document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n');
    5.         document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n');
    6.         document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n');
    7.     }
    8. </script>
    9.  
    10. <script>
    11. if (datefield.type!="date"){ //if browser doesn't support input type="date", initialize date picker widget:
    12.     jQuery(function($){ //on document.ready
    13.         $('#eventDate').datepicker({
    14. dateFormat: "dd-mm-yy"
    15. })
    16.     })
    17. }
    18. </script>

    In the past, this was always a work around for the lack of  compatibility with the Safari browser. Has something changed?