1
此功能適用於某些IE瀏覽器,但不起作用。 IE 8給我一個錯誤:JavaScript .split函數在所有瀏覽器中都不起作用
網頁錯誤的詳細信息
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.3; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET4.0C; .NET4.0E; MS-RTC LM 8) Timestamp: Wed, 25 Apr 2012 15:18:21 UTC
Message: Object doesn't support this property or method
Line: 9
Char: 17
Code: 0
URI: file:///G:/1.html
代碼:
GetLink();
function GetLink() {
selectedOption = "asdasdasd: asdasdas|asdadasd:asdadsasd|asdasdasd:asdasdad";
ROOM = selectedOption.split("|")[0].trim().split(":")[1].trim();
BUILDING = selectedOption.split("|")[1].trim().split(":")[1].trim();
var ret = "room_chart.jsp?room=" + ROOM + "&building=" + BUILDING;
return ret;
}
你也可以嘗試一些可能更快的修剪方法:http://blog.stevenlevithan.com/archives/faster-trim-javascript – Azmisov 2012-04-25 15:27:23