【发布时间】:2011-12-28 12:55:17
【问题描述】:
假设我们正在研究一个 url 字符串:
http:/domain.com/en/#the-file.html/section-4
我在哪里编码:
http:/domain.com/en/#{html file}/{id of the div}-{level}
这样我就可以知道了
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);
为我提供那些编码的变量
问题在于,例如,网址是
http://domain.com/es/
那个萤火虫会跳这个错误:
temp1 is undefined
知道如何预防吗?
【问题讨论】:
标签: javascript jquery split