如何从javascript获取codeigniter中的视图类名称?

时间:2013-04-06 16:07:11

标签: php codeigniter

我需要从js获取我的观点的类名。

说我的网址是

http://localhost/test/index.php/mytest/newtest/34

这里newtest是视图类的名称。我想从我的js获得这个类名。 我在谷歌搜索过它,但没有找到任何有用的东西。

提前致谢。

1 个答案:

答案 0 :(得分:2)

var pathArray = window.location.pathname;
pathArray = pathArray.replace(/^\/|\/$/g, '');
pathArray = pathArray.split( '/' );
console.log(pathArray);

使用此Javascript,您将从您的网址获取所有部分作为数组。在那里,您将知道您正在寻找的元素。