pkedpker Posted July 11, 2009 Share Posted July 11, 2009 Are those people just bad JavaScript programmers or is it a trick to get other browsers with bad JavaScript parsing to make it work? here is a example <script language="JavaScript"> <!-- function setsmiley(what){ tmp=document.getElementById("mytext"); tmp.value = tmp.value+" "+what+" "; tmp.focus(); } //--> </script> why the hell did he leave <!-- when --> is commented out anyways its pure stupidity from my side. Found this kind of error on google ads as well! had to remove the <!-- and //--> to save a few bytes! but is there any trick to this? leaving them in I mean Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/ Share on other sites More sharing options...
Zane Posted July 11, 2009 Share Posted July 11, 2009 http://www.w3.org/TR/REC-html40/interact/scripts.html The JavaScript engine allows the string "" from the JavaScript parser. Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/#findComment-873390 Share on other sites More sharing options...
.josh Posted July 11, 2009 Share Posted July 11, 2009 The point of it is back in the day when javascript was new enough that there were browsers that didn't know what to do with it, it was a hack to keep js from being displayed as plain text, if the browser didn't support it. So basically it's a backwards compatibility thing. Why people are still doing it I have no idea, as it's been a long time since virtually every single browser out there at least recognizes javascript. Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/#findComment-873513 Share on other sites More sharing options...
haku Posted July 11, 2009 Share Posted July 11, 2009 I don't like it either. Same as I don't like document.write Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/#findComment-873612 Share on other sites More sharing options...
Mchl Posted July 11, 2009 Share Posted July 11, 2009 Hey! I've no JS support in my mobile! Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/#findComment-873762 Share on other sites More sharing options...
haku Posted July 12, 2009 Share Posted July 12, 2009 Ya, but I doubt that sites that have javascript on them cause your browser to freak out. It's only the really old one that couldn't handle it. Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/#findComment-873806 Share on other sites More sharing options...
pkedpker Posted July 12, 2009 Author Share Posted July 12, 2009 Oi see Quote Link to comment https://forums.phpfreaks.com/topic/165580-solved-why-do-people-leave-comments-in-javascript-code/#findComment-873883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.