Javascript中的奇怪字符使其无法加载 [英] Strange characters in Javascript causing it to not load

查看:154
本文介绍了Javascript中的奇怪字符使其无法加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站在本地主机上工作正常,我的javascript正在加载并且正常工作。但是当我部署站点时,脚本不起作用。当我右键单击该页面并查看源代码,然后查看链接的脚本文件时,它在文件开头有一些奇怪的字符(function($){



在本地主机上,我的脚本文件像这样开始(function($){


解决方案

你必须重新保存文件编码没有BOM的UTF-8
您可以使用记事本++或其他编辑器。



在visual studio中:


默认情况下,Visual Studio与BOM使用UTF编码;但是,如果您愿意,可以将其保存为不同的编码。当您进入另存为对话框时,可以扩展保存按钮以查看使用编码保存选项,这将提示您输入不同的编码,我认为其中一个Unicode选项将省略BOM(列表中某处没有签名的是UTF-8)。


资料来源: http:// forums.silverlight.net/forums/t/144306.aspx


My site works fine on localhost, my javascript is loading and working fine. But when I deploy the site the script is not working. When I right click the page and say view source and then view the linked script file, it has some strange characters at the start of the file (function($){

On localhost, my script file starts like this (function($){

What is causing these characters to be prepended to my javascript file?

解决方案

You have to re-save the file in encoding "UTF-8 without BOM". You can use Notepad++ or other editors.

In visual studio:

By default, Visual Studio uses UTF encoding with the BOM; however, you can save it to a different encoding if you'd prefer. When you go to the Save As dialog, you can expand the Save button to see the 'Save with Encoding' option. This will prompt you for a different encoding, and I think one of the Unicode options will leave out the BOM (somewhere in the list is UTF-8 without signature).

Source: http://forums.silverlight.net/forums/t/144306.aspx

这篇关于Javascript中的奇怪字符使其无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆