讓說我們是天花板高度URL字符串:由字符串分割,並檢查零件,以防止錯誤
http:/domain.com/en/#{html file}/{id of the div}-{level}
這樣我可以知道:
http:/domain.com/en/#the-file.html/section-4
在那裏我有成文
var info = window.location.hash;
var temp = info.split("/");
var url = temp[0];
url = str_replace('#','',url);
var temp1 = temp[1];
temp1 = temp1.split('-');
var seccion = temp1[0];
var nivel = temp1[1];
其中
console.log('url: '+url);
console.log('info: '+nivel);
console.log('seccion: '+seccion);
我提供這些編纂瓦爾
問題時,例如,URL是
http://domain.com/es/
是螢火蟲跳這個錯誤:
temp1 is undefined
任何想法如何預防?
嘿!謝謝!工作和看起來更好:) – 2011-12-28 13:01:27