tags:

views:

46

answers:

2

Hello,

Many of you already familiar with Firebug Inspect option, which allow to move around in loaded web page and select web page Elements for inspection.

Maybe someone know any similar JavaScript which could do the same? I need to allow user to select and remove web page element at runtime. User visit web page, move mouse on elements and web element become selected, user click on element to remove it.

Any reference where I could start?

Regards, Tomas

A: 

There's Firebug Lite, Firebug packed as a javascript, to put in other browser than ff: http://getfirebug.com/firebuglite

Vincent
+1  A: 

I like a challenge.

Using jQuery, I've just made a simple example of how I would go about removing elements, visually. Check out a demo at roosteronacid.com/visualremove.

$(function ()
{
    $("* :not(body)").mouseenter(function ()
    {
        var that = $(this);

        var offset = that.offset();

        var a = $("<a />",
        {
            title: "Click to remove this element",
            css: {
                "position": "absolute",
                "background-color": "#898989",
                "border": "solid 2px #000000",
                "cursor": "crosshair",          
                width: that.width() + 6,
                height: that.height() + 2
            },
            offset: {
                top: offset.top - 4,
                left: offset.left - 4
            },          
            click: function ()
            {
                that.remove();

                a.remove();
            },
            mouseleave: function ()
            {
                a.fadeTo(200, 0, function ()
                {
                    a.remove();
                });
            }
        });

        that.after(a.fadeTo(200, 0.5));
    });
});
roosteronacid
Awesome! How can I contact you directly? I would like to discuss one issue.
Tomas
Contact me here, mate.
roosteronacid
You said that you like challenge ;) Do you have any idea how UNDO could be added to your demo? Let's say I remove several object and then click undo button to restore them?
Tomas
That's not a simple task--remember: you are removing elements from the DOM, not just hiding them. I'd suggest you just do a reload of the page, and let that serve as an undo function.
roosteronacid