admin管理员组

文章数量:1432006

Just getting started with Raphael.

Now I'm finding that paper.remove() is generating a script error:

 "SCRIPT5009: 'removed' is undefined 

Is this a script bug?

My variable paper is initialized thus:

var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);

My HTML body has:

<div id="canvas_container"></div>  

This is more info -- I am using Raphael 2.0 which I just downloaded again. Running IE9. Following is the Raphael JS function that is highlighted as the problem:

R.prototype.remove = function () {

        eve("remove", this);
        this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
        for (var i in this) {
            this[i] = removed(i);
        }
    };

the line ... removed(i) is highlighted --> SCRIPT5009: 'removed' is undefined

BTW I am new to this forum. Is there a way to respond to a thread other than "Answer Your Question"?

Just getting started with Raphael.

Now I'm finding that paper.remove() is generating a script error:

 "SCRIPT5009: 'removed' is undefined 

Is this a script bug?

My variable paper is initialized thus:

var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);

My HTML body has:

<div id="canvas_container"></div>  

This is more info -- I am using Raphael 2.0 which I just downloaded again. Running IE9. Following is the Raphael JS function that is highlighted as the problem:

R.prototype.remove = function () {

        eve("remove", this);
        this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
        for (var i in this) {
            this[i] = removed(i);
        }
    };

the line ... removed(i) is highlighted --> SCRIPT5009: 'removed' is undefined

BTW I am new to this forum. Is there a way to respond to a thread other than "Answer Your Question"?

Share Improve this question edited May 14, 2014 at 12:31 Margo 6824 gold badges13 silver badges30 bronze badges asked Oct 10, 2011 at 1:33 sudoku-sansudoku-san 411 silver badge4 bronze badges 1
  • Apart from answering a question, you can only enter-in ments. – Prisoner ZERO Commented Jun 15, 2012 at 16:40
Add a ment  | 

2 Answers 2

Reset to default 4

I've run across this a couple of times. The line 4443 method as suggested by sudoko-san does work in browsers but not backwards patible with IE-7 & 8 (the whole point of using raphael).

Another work around is to implement the following code in your javascript:

try{
    paper.remove();
}
catch (error) {
    // this catches the error and allows you to proceed along nicely
}

That's it!

I don't know if you've supplied enough information to answer this question.

  • What version of Raphael are you using?
  • On what browser?
  • Is it being loaded up correctly - can you create any Raphael objects?

If all you're doing is deleting the paper, see the fiddle below.

JSFiddle

It seems to work fine for me with Raphael 1.5.2

Hope that helps (even slightly).

本文标签: javascriptRaphael JSpaperremoveStack Overflow