Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created January 6, 2010 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subtleGradient/269990 to your computer and use it in GitHub Desktop.
Save subtleGradient/269990 to your computer and use it in GitHub Desktop.
Workaround for .NET breaking on `clientID.startsWith`
// Workaround for .NET breaking on `clientID.startsWith`
// Name: MicrosoftAjaxWebForms.debug.js
// Assembly: System.Web.Extensions
// Line: 722
// Error: Object doesn't support this property or method
/*
function Sys$WebForms$PageRequestManager$_matchesParentIDInList
(clientID, parentIDList) {
for (var i = 0, l = parentIDList.length; i < l; i++) {
if (clientID.startsWith(parentIDList[i] + "_")) {
return true;
}
}
return false;
}
*/
// Workaround
Function.prototype.startsWith = function(){ return false; };
// Explaination of what's going wrong with this code
while (element) {
if (element.id) element.id.startsWith("whatever");
// when element is an Element its `id` is a string
// when element is a Document its `id` is usually undefined
// when a JavaScript framework sets document.id to a function,
// its `id` will not have the `startsWith` method
//
// If they used `element.getAttribute('id')` instead, this wouldn't be a problem
// If JavaScript frameworks did not set document.id to a function then this wouldn't be a problem
element = element.parentNode;
}
// Complete original source
// from http://www.infinitezest.com/SourceViewer/AJAXSourceMethod.aspx?Method=_getPostBackSettings(element,%20elementUniqueID)
function Sys$WebForms$PageRequestManager$_getPostBackSettings(element, elementUniqueID) {
var originalElement = element;
var proposedSettings = null;
while (element) {
if (element.id) {
if (!proposedSettings && Array.contains(this._asyncPostBackControlClientIDs, element.id)) {
proposedSettings = this._createPostBackSettings(true, this._scriptManagerID + '|' + elementUniqueID, originalElement);
}
else {
if (!proposedSettings && Array.contains(this._postBackControlClientIDs, element.id)) {
return this._createPostBackSettings(false, null, null);
}
else {
var indexOfPanel = Array.indexOf(this._updatePanelClientIDs, element.id);
if (indexOfPanel !== -1) {
if (this._updatePanelHasChildrenAsTriggers[indexOfPanel]) {
return this._createPostBackSettings(true, this._updatePanelIDs[indexOfPanel] + '|' + elementUniqueID, originalElement);
}
else {
return this._createPostBackSettings(true, this._scriptManagerID + '|' + elementUniqueID, originalElement);
}
}
}
}
if (!proposedSettings && this._matchesParentIDInList(element.id, this._asyncPostBackControlClientIDs)) {
proposedSettings = this._createPostBackSettings(true, this._scriptManagerID + '|' + elementUniqueID, originalElement);
}
else {
if (!proposedSettings && this._matchesParentIDInList(element.id, this._postBackControlClientIDs)) {
return this._createPostBackSettings(false, null, null);
}
}
}
element = element.parentNode;
}
if (!proposedSettings) {
return this._createPostBackSettings(false, null, null);
}
else {
return proposedSettings;
}
}
@sri2108
Copy link

sri2108 commented Nov 8, 2013

Hi,

I am using mootools in sharepoint 2013.
I am getting error in ie8 as "Object doesn't support this property or method". in my sharepoint master page I included as below

<script type="text/javascript" src="/sites/clientcide-mootools-2.10.js">// </script> <script type="text/javascript" src="/sites/pagefunctions.js">// </script> <script type="text/javascript" src="/sites/SuggestedSearch.js">// </script> <script type="text/javascript" src="/sites/SuggestedData.js">// </script> <script type="text/javascript" src="/sites/Navigation.js">// </script>

Not sure where it is conflicting. Please help me out with solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment