Xpath with js and google chrome
I have a code for generating xpath on click but i need to put that in an chrome extension. So how to do that?
Here is the code for generating xpath on click:
function get_XPath(elt)
{var path = '';
for (; elt && elt.nodeType==1; elt=elt.parentNode)
{var idx=$(elt.parentNode).children(elt.tagName).index(elt)+1;
idx>1 ? (idx='['+idx+']') : (idx='');
path='/'+elt.tagName.toLowerCase()+idx+path;
}
return path;
}
$(document).ready(function() {
$('*').click(function(event) {
event.stopPropagation();
alert(get_XPath(this));
});
});
also you will see the demo here: http://jsfiddle.net/CksqX/
How i can construct an chrome extension so when I click on some element on chrome current page to get xpath with my function in textfiled ?
How to pack this code to work as chrome extension?
Maybe the code is not very well but i will fix them, so i need to turn this into google chrome extension
sorry about trivial question,i'm new to web developing and sorry for my englsh
您应该指定此https://developer.chrome.com/extensions/getstarted.htmlвщс您不明白的具体部分,以便我们可以本地化您的问题
链接地址: http://www.djcxy.com/p/91132.html上一篇: 如何解释k的结果
下一篇: 带有js和谷歌浏览器的Xpath