Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author urvanov

    (@urvanov)

    Hi, @aakashmittalwp578 . Thank you for writing.

    Please attach the text with error message from the console.

    Thread Starter aakashmittalwp578

    (@aakashmittalwp578)

    I am receiving this error in console

    urvanov_syntax_highlighter.min.js?ver=2.8.40:1 Uncaught TypeError: Cannot read properties of undefined (reading ‘writeText’)
    at J.copyPlain (urvanov_syntax_highlighter.min.js?ver=2.8.40:1:13921)
    at HTMLDivElement. (urvanov_syntax_highlighter.min.js?ver=2.8.40:1:8549)
    at HTMLDivElement.dispatch (jquery.min.js?ver=3.7.1:2:40035)
    at v.handle (jquery.min.js?ver=3.7.1:2:38006)

    J.copyPlain = function(ak, al) {
    if (typeof B[ak] == “undefined”) {
    return aa(ak)
    }
    var aj = B[ak].plain;
    var ai = aj[0].value;
    navigator.clipboard.writeText(ai).then(function(am) {
    return I(ak, H.copy)
    });
    return false
    }

    In this code

    base.copyPlain = function (uid, hover) {

    if (typeof urvanov_syntax_highlighters[uid] == 'undefined') {

    return makeUID(uid);

    }

    var plain = urvanov_syntax_highlighters[uid].plain;

    var plainTextCode = plain[0].value;

    navigator.clipboard.writeText(plainTextCode)

    .then(function(value) {

    return urvanovSyntaxHighlighterInfo(uid, strings.copy);

    });

    return false;

    };

    Plugin Author urvanov

    (@urvanov)

    Looks like navigator.clipboard is undefined.

    I checked it in MDN https://developer.mozilla.org/en-US/docs/Web/API/Clipboard now.

    Clipboard is available only in HTTPS. I think you host your site on localhost with HTTP or somewhere else with HTTP. So, copy button will not work this way.

    Thread Starter aakashmittalwp578

    (@aakashmittalwp578)

    Yes, I am checking on localhost.

    Thanks for your support

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Copy code button not working’ is closed to new replies.