The EXACT same code doesn't work as it should in Dreamweaver

允我心安 提交于 2019-12-11 12:46:22

问题


Sometimes when I copy javascript from jsfiddle into Dreamweaver I end up banging my head in the wall. Two documents with (what looks to be) the EXACT same javascript doesn't work in the same way.

In document A I have the following code:

<script>
alert('test')
</script>

In document B I have the following code (does not work):

<script>
alert('test')
​</script>

Note: Please copy code B in to a html document and try if it alert before giving me comments. I am not joking, there is something weird going on.

I have located the problem to be something with the end script tag, but I can't see any thing wrong with the code.

Whats the difference in the code from document A and B?


回答1:


You've got an Zero-width space (U+8203) behind the closing bracket.

The bug is known to jsfiddle, it seems to be an issue with the codemirror syntax highlighter.




回答2:


When copy and pasting the javascript code from jsfiddle (using Chrome browser) into Dreamweaver I get a invisable Unicode charactar at the end of the script.

This little one: "​" (yes there is a character between those...)

This mess up the javascript and it is hard to locate the problem.

If you have a similar problem as mine you can search for the character by copying it from the "" above.




回答3:


Try:

<script type="text/javascript">
    alert("Test");
</script>

HTH




回答4:


Where do you put this code in the page ?

Try using <script type="text/javascript"> instead of just <script>.

In order to work, you script need to be anywhere between <head></head> or <body></body>.

Have you try another browser ? Are you sure Javascript is enabled ?



来源:https://stackoverflow.com/questions/11234578/the-exact-same-code-doesnt-work-as-it-should-in-dreamweaver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!