Does anyone know a DOM inspector javascript library or plugin?

前端 未结 11 1704
你的背包
你的背包 2020-12-14 03:54

Does anyone know of a DOM inspector javascript library or plugin?

I want to use this code inside a website I am creating, I searched a lot but didn\'t find what I wa

11条回答
  •  孤城傲影
    2020-12-14 04:32

    Very recently, I needed to develop an application using JavaScript : when any user click on an image of this site, it will send image URL to a specific location. Here is the article that helped me achieve that : AspBoss - Javascript Library for Dom Inspector

    And this is the code :

    // DOM Inspector
    // version 0.1
    // 2006-01-25
    // Copyright (c) 2006, Onur Mat
    //
    // --------------------------------------------------------------------
    //
    // This user script allows you to interact with elements of a web page
    // by moving mouse pointer on a web page and clicking on selected elements.
    //
    // To install for Firefox, you need Greasemonkey: http://greasemonkey.mozdev.org/
    // Then restart Firefox and revisit this script.
    // Under Tools, there will be a new menu item to "Install User Script".
    // Accept the default configuration and install.
    //
    // To install for Internet Explorer, you need Turnabout:
    // http://www.reifysoft.com/turnabout.php
    // See instructions for using Turnabout here:
    // http://www.reifysoft.com/turnabout.php
    //
    // --------------------------------------------------------------------
    //
    // ==UserScript==
    // @name          DOM Inspector
    // @namespace     http://www.dominspector.com/
    // @description   Inspect DHTML DOM elements interactively
    // @include       *
    // ==/UserScript==
    
    function DIOnMouseOver(evt)
    {
        element = evt.target;   // not IE
    
        // set the border around the element
        element.style.borderWidth = '2px';
        element.style.borderStyle = 'solid';
        element.style.borderColor = '#f00';
    }
    
    
    function DIOnMouseOut(evt)
    {
        evt.target.style.borderStyle = 'none';
    }
    
    
    function DIOnClick(evt)
    {
        var selection = evt.target.innerHTML;
    
        alert('Element is: ' + evt.target.toString() + '\n\nSelection is:\n\n' + selection);
        return false;
    }
    
    
    document.addEventListener("mouseover", DIOnMouseOver, true);
    document.addEventListener("mouseout", DIOnMouseOut, true);
    document.addEventListener("click", DIOnClick, true);
    

提交回复
热议问题