1

I am creating a Cordova hybrid app. I use the Facebookconnectplugin and show up a tutorial on first start. This works for every Supported Plattform and Version (Android / iOS) but not for Android 4.1 Here the code breaks with "Object # has no method 'remove'". It Breaks all the time at the line when I try to remove the fadeMe div. As said works everywhere else (Android 4.3+ / iOS 7+)

facebookConnectPlugin.login(["public_profile", "email", "user_friends"],
    function (response) {
        //check if this is startup then remove overlay
        if(document.getElementById("fadeMe")){
            document.getElementById("fadeMe").remove();//document.body.removeChild(div);
            describeTableView();
        }
    }
);

CSS:

#fadeMe{
  background-color: rgba(0,0,0,.75); 
  width:      100%;
  height:     100%; 
  z-index:    11;
  top:        0; 
  left:       0; 
  position:   fixed;
  color: #ffffff;
  padding-left: 20px;
  padding-top: 20px;
  font-size: 0.9em;
  font-weight: 300;

  webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
       -moz-animation: fadein 2s; /* Firefox < 16 */
        -ms-animation: fadein 2s; /* Internet Explorer */
         -o-animation: fadein 2s; /* Opera < 12.1 */
            animation: fadein 2s;
}

And it is created like this:

var div = document.createElement("div");
div.setAttribute('class', 'fadeMe');
div.setAttribute('id', 'fadeMe');
document.body.appendChild(div);

Found a similar question but without answer: Similar Question

2
  • 1
    The browser probably doesn't support childNode.remove, consider a polyfill.
    – MinusFour
    Oct 5, 2015 at 13:50
  • yes I copied this in onDeviceReady and for the first look this fixed it! thank you! Oct 5, 2015 at 13:56

1 Answer 1

2

Using Polyfill does the trick:

if (!('remove' in Element.prototype)) {
    Element.prototype.remove = function() {
        this.parentNode.removeChild(this);
    };
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.