\u200b (Zero width space) characters in my JS code. Where did they come from?

前端 未结 5 644
失恋的感觉
失恋的感觉 2020-11-27 04:05

I am developing a front end of a web app using NetBeans IDE 7.0.1. Recently I had a very nasty bug, which I finally fixed.

Say I have code

var elemen         


        
5条回答
  •  甜味超标
    2020-11-27 04:44

    As Mr Shawn Chin has addressed it already. I just happened to replicate the issue while I was copy pasting jquery code from a webpage.

    When it happened: Copying text from Google Chrome Version 41.0.2272.118 m ( not tested with other browsers ) to Dreamweaver code window. This copied unwanted characters along the code like this happening here

    you copied text from a webpage as

    $('.btn-pageMenu').css('display'​​​​​​​​​​​​​​​​​​​​​​​​​​​,'block');​​​​​​
    

    behind the scenes, this is what makes that line

    $('.btn-pageMenu').css('display'​​​​​​​​​​​​​​​​​​​​​​​​​​​,'block');​​​​​​
    

    Copied to an advanced editor like those you mentioned or Dreamweaver gives errors in browser, probably failing of javascript code too

    Uncaught SyntaxError: Unexpected token ILLEGAL
    

    Solution: When it happens, embrace the worth of notepad until this gets fixed by the big guys. It is more related to the editor then the browsers.

提交回复
热议问题