例子:var url = "http://localhost:64177/Home/AccordionIndex";

将斜杠转换成反斜杠:

url = url .replace("\/\/", "\\\\");
url = url .replace("\/", "\\");
url = url .replace("\/", "\\");

alert(url);

将会弹出:http:\\localhost:64177\Home\AccordionIndex

 

将反斜杠转换成斜杠:

var strurl = "http:\\localhost:64177\Home\AccordionIndex";

strurl = strurl .replace("\\\\", "\/\/");
strurl = strurl .replace("\\", "\/");
strurl = strurl .replace("\\", "\/");
alert(strurl );

将会弹出:http://localhost:64177/Home/AccordionIndex