将元关键字写入新(浏览器)选项卡的Javascript Bookmarklet
所以我设法让它工作(脚本提取站点元关键字并将其写入DOM) 但不知道如何将两者结合起来。请帮忙 试试这个:将元关键字写入新(浏览器)选项卡的Javascript Bookmarklet,javascript,html,dom,bookmarklet,Javascript,Html,Dom,Bookmarklet,所以我设法让它工作(脚本提取站点元关键字并将其写入DOM) 但不知道如何将两者结合起来。请帮忙 试试这个: (function metaKeywords() { metaCollection = document.getElementsByTagName('meta'); for (i = 0; i < metaCollection.length; i++) { nameAttribute = metaCollection[i].name.search(/k
(function metaKeywords() {
metaCollection = document.getElementsByTagName('meta');
for (i = 0; i < metaCollection.length; i++) {
nameAttribute = metaCollection[i].name.search(/keywords/);
if (nameAttribute != -1) {
var str = (metaCollection[i].content);
window.open('javascript:document.write("' + str + '")');
window.focus();
}
}
})();
(函数元关键字(){
metaCollection=document.getElementsByTagName('meta');
对于(i=0;i
或作为一个班轮:
javascript:(function metaKeywords() { metaCollection = document.getElementsByTagName('meta'); for (i = 0; i < metaCollection.length; i++) { nameAttribute = metaCollection[i].name.search(/keywords/); if (nameAttribute != -1) { var str = (metaCollection[i].content); window.open('javascript:document.write("' + str + '")'); window.focus();}}})();
javascript:(function metaKeywords(){metaCollection=document.getElementsByTagName('meta');for(i=0;i
您打开一个新窗口(确保它没有被阻止),并将其设置为将字符串写入内容。jsiddle不允许document.write,因此我无法向您展示演示,但它可以在我的机器(TM)上运行。p.S.请不要使用JQUERY:)非常有效!谢谢大家!@和斯特林
(function metaKeywords() {
metaCollection = document.getElementsByTagName('meta');
for (i = 0; i < metaCollection.length; i++) {
nameAttribute = metaCollection[i].name.search(/keywords/);
if (nameAttribute != -1) {
var str = (metaCollection[i].content);
window.open('javascript:document.write("' + str + '")');
window.focus();
}
}
})();
javascript:(function metaKeywords() { metaCollection = document.getElementsByTagName('meta'); for (i = 0; i < metaCollection.length; i++) { nameAttribute = metaCollection[i].name.search(/keywords/); if (nameAttribute != -1) { var str = (metaCollection[i].content); window.open('javascript:document.write("' + str + '")'); window.focus();}}})();