{"id":1153,"date":"2012-11-08T11:57:44","date_gmt":"2012-11-08T10:57:44","guid":{"rendered":"http:\/\/blog.kodono.info\/wordpress\/?p=1153"},"modified":"2012-11-08T11:57:44","modified_gmt":"2012-11-08T10:57:44","slug":"webpart-doesnt-work-with-ie8-in-standard-mode-under-sharepoint-2010","status":"publish","type":"post","link":"https:\/\/blog.kodono.info\/wordpress\/2012\/11\/08\/webpart-doesnt-work-with-ie8-in-standard-mode-under-sharepoint-2010\/","title":{"rendered":"WebPart doesn&#8217;t work with IE8 in standard mode under Sharepoint 2010"},"content":{"rendered":"<p>The Microsoft developers are not really good, and we can see it if you use IE8 in standard mode with Sharepoint 2010: the web parts don&#8217;t work anymore due to an error with the wpadder.js file.<br \/>\nAfter few hours trying to find the problem I&#8217;ve finally discovered that the WPAdder class uses the <code>for..in<\/code> statement without testing the <code>hasOwnProperty<\/code> (<a href=\"http:\/\/stackoverflow.com\/questions\/9085018\/ie8-for-in-enumerator\" title=\"Link to Stackoverflow regarding the for..in problem\">more about that problem<\/a>), then it causes some issues&#8230;<\/p>\n<p>Here is how I fixed it (this code must be added after the DOM is loaded in the master page to be called by all the pages) :<\/p>\n<pre class=\"brush:javascript\">\r\nEnsureScript(\"WPAdderClass\", undefined, function() {\r\n  if (typeof loadWPAdderCallback === \"function\") {\r\n    var _loadWPAdderCallback=loadWPAdderCallback;\r\n    loadWPAdderCallback = function() {\r\n      _WPAdder.prototype._layout = function (a) {\r\n        ULSior: ;\r\n        var l = this._saveDescriptionForLayout();\r\n        if (this._lastLayoutWidth == -1) {\r\n          var g = this._getCategoryContainer();\r\n          for (var b in this._cats) {\r\n            if (this._cats.hasOwnProperty(b)) g.appendChild(this._cats[b].el)\r\n          }\r\n        }\r\n        if (this._table.clientHeight != this._lastLayoutHeight) {\r\n          this._selCat != -1 &#038;& this._removeItemHover();\r\n          this._layoutCategoryColumn();\r\n          this._getNavigationTable().parentNode.colSpan = 1;\r\n          var d = 0,\r\n          f = 0,\r\n          c = document.createElement(\"DIV\"),\r\n          g = this._itemContainerTemplate.cloneNode(true);\r\n          c.style.whiteSpace = \"nowrap\";\r\n          c.style.width = \"1px\";\r\n          c.style.height = \"1px\";\r\n          c.style.overflow = \"auto\";\r\n          c.innerHTML = \"Quick Brown Fox!<br\/>It jumped!\";\r\n          this._getFirstChild(g).appendChild(c);\r\n          this._getItemContainer().appendChild(g);\r\n          var j = c.scrollWidth,\r\n          i = c.scrollHeight;\r\n          this._removeElement(g);\r\n          if (a &#038;& (parseInt(a[0][0]) != j || parseInt(a[0][1]) != i || parseInt(a[0][2]) != this._table.clientHeight)) a = null;\r\n          if (a) {\r\n            d = parseInt(a[0][3]);\r\n            for (var b = 0; b < this._cats.length; b++) {\r\n              if (this._cats.hasOwnProperty(b)) {\r\n                var e = this._fillCachedItems(this._cats[b].items, this._itemContainerTemplate, a[b + 1]);\r\n                if (e.length > f) f = e.length;\r\n                this._cats[b].itemCols = e\r\n              }\r\n            }\r\n          } else {\r\n            a = \"\";\r\n            for (var b in this._cats) {\r\n              if (this._cats.hasOwnProperty(b)) {\r\n                var e = [],\r\n                h = this._fillItems(e, this._cats[b].items, this._getItemContainer(), this._itemContainerTemplate, _WPAdder_maximumItemWidth);\r\n                if (h[1] > d) d = h[1];\r\n                if (e.length > f) f = e.length;\r\n                this._cats[b].itemCols = e;\r\n                a += \";\" + h[0]\r\n              }\r\n            }\r\n            a = j + \",\" + i + \",\" + this._table.clientHeight + \",\" + d + a;\r\n            this._getHiddenField(\"layout\").value = this._layoutHash + \";\" + a\r\n          }\r\n          for (var b in this._cats) {\r\n            if (this._cats.hasOwnProperty(b)) {\r\n              var k = this._cats[b].itemCols;\r\n              for (var m in k) {\r\n                if (k.hasOwnProperty(m)) this._finishColumn(k[m], d)\r\n              }\r\n          }\r\n        }\r\n        for (var b in this._dummyCols) {\r\n          if (this._dummyCols.hasOwnProperty(b)) this._finishColumn(this._dummyCols[b], d);\r\n        }\r\n        this._maxCols = f;\r\n        this._widestColumn = d\r\n        }(this._table.clientWidth != this._lastLayoutWidth || this._table.clientHeight != this._lastLayoutHeight) &#038;& this._calculateVisibleItemColumns();\r\n        this._restoreDescriptionAndLayout(l);\r\n        this._lastLayoutWidth = this._table.clientWidth;\r\n        this._lastLayoutHeight = this._table.clientHeight\r\n      };\r\n      _WPAdder.prototype._removeItemHover = function () {\r\n        ULSior: ;\r\n        var a = this._getItems();\r\n        for (var b in a) {\r\n          if (a.hasOwnProperty(b)) a[b].removeHover()\r\n        }\r\n      };\r\n      _loadWPAdderCallback();\r\n    }\r\n  }\r\n})\r\n<\/pre>\n<p>Actually, when we load the WPAdder class, then I override the two functions that are buggy in adding the <code>hasOwnProperty<\/code>. That&#8217;s it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Microsoft developers are not really good, and we can see it if you use IE8 in standard mode with Sharepoint 2010: the web parts don&#8217;t work anymore due to an error with the wpadder.js file. After few hours trying to find the problem I&#8217;ve finally discovered that the WPAdder class uses the for..in statement [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","hide_page_title":"","footnotes":""},"categories":[15,13,33],"tags":[24,158,117],"class_list":["post-1153","post","type-post","status-publish","format-standard","hentry","category-astuce","category-niveau-intermediaire","category-programmation","tag-javascript","tag-programmation","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1153"}],"version-history":[{"count":1,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1153\/revisions"}],"predecessor-version":[{"id":1154,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1153\/revisions\/1154"}],"wp:attachment":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}