如何获取html标题元素
因为我想发送 中包含的文件名部分例如 css & js 文件名
,包括其容器文件夹,通过ajax
发送到服务器端。
请注意,在给定的示例中, css & js
位于 files 文件夹内。
那么我怎样才能获得 css 和js 文件名,包括它的容器
<html> <head>
<link rel="stylesheet" href="files/sample.css"/>
<script type="text/javascript" src="files/jquery.js"> </script>
</head>
现在我还需要考虑其他事情,sample.CSS
#myImage {
background: url('image/lucy.jpg');
/* also i need to get these image file name including details with location */
}
as i want to send the file names which is included in <head> section e.g. css & js file name
including it's container folder to the server side via ajax
.
please note that, in given example the css & js
are located inside of files folder.
so how can i get the css & js file names including it's container
<html> <head>
<link rel="stylesheet" href="files/sample.css"/>
<script type="text/javascript" src="files/jquery.js"> </script>
</head>
Now i need to consider about other things too, sample.CSS
#myImage {
background: url('image/lucy.jpg');
/* also i need to get these image file name including details with location */
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是为了获取
head
元素中的资源名称(样式表和脚本):实际解析这些文件并计算它们的完整路径相当困难。要获取所有图像,您可以考虑遍历所有 dom 元素并检查它们是否通过 css 附加了任何
background-image
:这种方法的好处是您不需要将相对路径转换为完整路径,因为 jquery 正在为你做这件事。
this is to get the resources names (stylesheets and scripts) in your
head
element :It's rather hard to actual parse these files and compute their fullpath. To get all the images, you may consider to traverse all of the dom elements and check if they have any
background-image
attached to them through css :The good thing about this approach is that you do not have to transform the relative path into full path, because jquery is doing that for you.
我不确定你想要做的事情是否可以通过网络浏览器实现 - 但有一些工具可以在没有 -> 的情况下完成它。 http://www.httrack.com/html/overview.html
Im not sure what you want to do is possible from a web browser - but there are tools that will do it without -> http://www.httrack.com/html/overview.html