我用 JQuery 构建了一个包含许多 JavaScript 函数的 Intranet ASP Razor MVC 4 网站。当网站发布时,javascript 会发生奇怪的转换:
发布前:
$(function()
{
$("#btnSettings").click(function ()
{
$("#dialog-Settings").dialog("open");
});
$("#dialog-Settings").dialog(
{
resizable: false,
height: 200,
width: 350,
modal: true,
autoOpen: false,
buttons:
{
"Save": function ()
{
var server = $("#serverTitle-Name").text();
$.get(
'@Url.Action("SaveSettings")',
{ serverName: server },
function (responseText)
{
if (responseText.length > 4)
{
alert(responseText);
}
}
);
$(this).dialog("close");
},
Cancel: function ()
{
$(this).dialog("close");
}
}
});
});
发布后(实时站点):
try{if(window.__vwd)__vwd.push(__vwdLid,"","",6672,110);$("#btnSettings").click(function ()
{var __vwdLid=window.__vwd?++__vwd.nextSid:0;
try{if(window.__vwd)__vwd.push(__vwdLid,"","",6732,37);$("#dialog-Settings").dialog("open");}finally{if(window.__vwd)__vwd.pop();}
});}finally{if(window.__vwd)__vwd.pop();}
try{if(window.__vwd)__vwd.push(__vwdLid,"","",6794,980);$("#dialog-Settings").dialog(
{
resizable: false,
height: 200,
width: 350,
modal: true,
autoOpen: false,
buttons:
{
"Save": function ()
{var __vwdLid=window.__vwd?++__vwd.nextSid:0;
var server = $("#serverTitle-Name").text();
try{if(window.__vwd)__vwd.push(__vwdLid,"","\"Save\"",7154,403);$.get(
'/Home/ResolveError',
{ serverName: server },
function (responseText)
{var __vwdLid=window.__vwd?++__vwd.nextSid:0;
try{if(window.__vwd)__vwd.push(__vwdLid,"","",7362,144);if (responseText.length > 4)
{
try{if(window.__vwd)__vwd.push(__vwdLid,"","",7455,20);alert(responseText);}finally{if(window.__vwd)__vwd.pop();}
}}finally{if(window.__vwd)__vwd.pop();}
}
);}finally{if(window.__vwd)__vwd.pop();}
try{if(window.__vwd)__vwd.push(__vwdLid,"","\"Save\"",7581,24);$(this).dialog("close");}finally{if(window.__vwd)__vwd.pop();}
},
Cancel: function ()
{var __vwdLid=window.__vwd?++__vwd.nextSid:0;
try{if(window.__vwd)__vwd.push(__vwdLid,"","Cancel",7703,24);$(this).dialog("close");}finally{if(window.__vwd)__vwd.pop();}
}
}
});}finally{if(window.__vwd)__vwd.pop();}
为什么 ASP 像这样转换我的 JavaScript?我该如何阻止它?