Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从当前url中选取html页面标题中的数据_Html - Fatal编程技术网

如何从当前url中选取html页面标题中的数据

如何从当前url中选取html页面标题中的数据,html,Html,如何从当前url中选择html页面标题中的数据 我的网址是 file:///D:/Documents%20and%20Settings/Desktop/HTML/Basic2.html?course_id=CO2 我想把标题写为: 为“课程id”的培训添加优先权 在上述过程中,id应为CO2 员工培训优先权 添加优先权 我使用get value函数获取URL中的值。使用javascript可以获取当前路径,如: var pathname = window.location.pathnam

如何从当前url中选择html页面标题中的数据

我的网址是

file:///D:/Documents%20and%20Settings/Desktop/HTML/Basic2.html?course_id=CO2

我想把标题写为:

为“课程id”的培训添加优先权

在上述过程中,id应为CO2

员工培训优先权
添加优先权


我使用get value函数获取URL中的值。

使用javascript可以获取当前路径,如:

var pathname = window.location.pathname;
从中可以找到课程id的索引,其中包括:

var index =pathname.indexOf("course_id");

最后,您需要课程id,您可以通过使用子字符串获得:

var courseID = pathname.substr(index).

希望这能帮到你。

URL是从哪里来的?你是否将URL设置为类似于
basic2.html?课程id=“.objResult[“课程id”]”。
?或者,您是如何创建URL的?
var index=pathname.indexOf("=");
var courseID = pathname.substr(index).