     meta = document.createElement 'meta'
     meta.setAttribute 'name','original-url'
     meta.setAttribute 'content', url
-    DOM.getElementsByTagName('head')[0].appendChild meta
+    head = (
+      DOM.getElementsByTagName('head')[0] ?
+      DOM.getElementsByTagName('body')[0]
+    )
+    head.insertBefore meta, head.children[0]
 
   createNewObj: (obj, str) ->
     frames = obj.document.getElementsByTagName 'iframe'

    src = "<!DOCTYPE "
    elem = ""
    for i in [0...array.length]
      if i == 1
        src += "PUBLIC " + '"' + array[i] + '" '
      if i == 2
        src += '"' + array[i] + '"'
      if i == 0
        src+= array[i] + " "
      #console.log src
    return src + ">"


    if counter == 0 and @flag == true and counter1 == 0
      #console.log @dictionary
      @createNewObj @dictionary[""],""
      _url = @dictionary[""].url
      console.warn "!!! URL=", _url
      _doc = @cleanUp @dictionary[""].document, _url
      file = new File([
        @getAttribute(
          @dictionary[""].header,@dictionary[""].doctype
        ),
        _doc.innerHTML,
        "</html>"
        ],
        (_doc.getElementsByTagName('title')[0]?.innerHTML ? _url) + ".html",
        {type: "text/html;charset=utf-8"}
      )
      FileSaver.saveAs(file)
