Jump to content
Fórum Script Brasil
  • 0

Copiar e colar imagem


Wellington Gallo
 Share

Question

Boa tarde, esse codigo de copiar e colar imagem só roda no chrome , queria saber como posso adaptar para o ie e o firefox, é através do clipboardData né ? Mas como que eu faço isso ?

$(document).ready(function() {
            window.addEventListener("paste",processEvent);

            function processEvent(e) {
                for (var i = 0 ; i < e.clipboardData.items.length ; i++) {

                    // get the clipboard item
                    var clipboardItem = e.clipboardData.items[i];
                    var type = clipboardItem.type;

                    // if it's an image add it to the image field
                    if (type.indexOf("image") != -1) {

                        // get the image content and create an img dom element
                        var blob = clipboardItem.getAsFile();
                        var blobUrl = window.webkitURL.createObjectURL(blob);
                        var img = $("<img/>");
                        img.attr("src",blobUrl);

                        // our slider requires an li item.
                        var li = $("<li></li>");

                        // add the correct class and add the image
                        li.addClass("bjqs-slide");
                        li.append(img);

                        // add this image to the list of images
                        $(".bjqs").append(li);

                        // reset the basic-slider added elements
                        $(".bjqs-controls").remove();
                        $(".bjqs-markers").remove();

                        // reset the image slider
                        $('#banner-fade').bjqs({
                            height      : 320,
                            width       : 620,
                            responsive  : true
                        });
                    } else {
                        console.log("Not supported: " + type);
                    }

                }
            }
        });
Edited by Wellington Gallo
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...