简体   繁体   中英

alert errors from console

I'm using a tabletop js to connect my javascript to spreadsheet.

JSfiddle: https://jsfiddle.net/fbLdxqdp/2/ I have this onclick button function to submit the url of my spreadsheet:

$("button").click(function(){
    // find closes textareau in this specific button DIV
    $(this).parent().find('textarea').select();
    document.execCommand('copy');
    
    var error_msg = console.error(message); 
    alert(error_msg)
});

If I enter the URL correctly, then I can work on the spreadsheet w/o any issues.

BUT if i have the wrong URL, i will get a console error.

How can I alert my self if I enter the wrong URL? Please see this screenshot for the error console: https://www.screencast.com/t/SAVKUn8V

the full javascript html: https://pastebin.com/DP6dkyxr

In your code you have assigning return value of console.error to error_msg there is no such a thing console.error don't return a value.

try as follows,

 alert(message)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM