none
How to copy alert message of edge browser RRS feed

  • Question

  • Hi,

    I am working on the extension for edge browser. From my extension I am displaying some string on the popup by using alert().

    But I am not able to copy this string from that alert popup. Neither I am able to select the string with my mouse, not Ctrl+C is working for copying the string.

    where as same alert string I can copy from chrome browser, but not able to copy here in edge browser.

    Please guide, how can I copy the text of the alert popup in edge browser.

    Thanks In advance,

    Regards

    Mayank


    Thanks & Regards, Mayank Agarwal

    Tuesday, August 21, 2018 8:48 AM

All replies

  • Hi MayankAg,

    I try to check and find that in MS Edge it is not working and it is not possible to copy the text from popup.

    You can use Ctrl + C in Internet Explorer and it can able to copy all the text from popup.

    But in Edge, It is not possible to copy text from alert box , popups, dialog or error.

    I also check but there is no any other way or work around to copy the text.

    So at present, It is not possible to fulfill this requirement.

    Regards

    Deepak 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 22, 2018 4:44 AM
    Moderator
  • Thanks Deepak for your reply.

    Is it a defect or a feature in MS Edge that I cannot copy the alert message? where as all other browser supports for same.

    I need to provide the copy message feature for my extension alert.

    Can I programmatically copy the string(popup) contents in a clipboard and later once the popup appears I will ask user to just make use of Ctrl+V to paste the clipboard string to any notepad.

    Or there may be any other way to take the string out of that popup.

    Please guide.

    Regards,

    MayankAg


    Thanks & Regards, Mayank Agarwal

    Wednesday, August 22, 2018 5:11 AM
  • Hi MayankAg,

    You can use code below to copy the text using JavaScript.

    function myFunction() {
      var copyText = document.getElementById("myInput");
      copyText.select();
      document.execCommand("copy");
      alert("Copied the text: " + copyText.value);
    }

    Further, You can modify it to work with Alert().

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 22, 2018 8:22 AM
    Moderator
  • Thanks Deepak for your  reply.

    But alert is not the html element, therefore this document.getElementById() will not work here.

    Regards,

    MayankAg


    Thanks & Regards, Mayank Agarwal

    Thursday, August 23, 2018 9:05 AM
  • Hi MayankAg,

    Try to refer example below may help you.

    window.alert = (function(al) {
        return function(text) {
            // your stuff here...
            al(text);
        };
    })(window.alert);

    Or

    function getAlert() {
    
      // get all scripts
      var elem = document.scripts;
    
      // loop and check
      for (var i = 0, len = elem.length; i < len; i++) {
    
        var txt = elem[i].textContent.match(/alert\(['"]([^'"]+)['"]\)/);
        if (txt) { return txt[1]; } // if matched, return the alert text and stop
      }
    } 

    Reference:

    Capture text displayed on JavaScript Alert message

    How to get text from alert box?

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 24, 2018 7:38 AM
    Moderator