您好我正在尝试创建一个书签,它将打开一个网页,在该页面上找到一个下载链接,然后关闭该网页。除非有更好的方法,否则我会打开页面,调用就绪(我认为这是不工作的部分),然后搜索下载链接。导入jQuery的代码取自:http ://coding.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/
javascript:(function() {
var v = "1.3.2";
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName("head")[0].appendChild(script);
}
else {
initMyBookmarklet();
}
function initMyBookmarklet() {
var ytm = window.open('http://example.com');
jQuery(document).ready(function() {
var div = ytm.document.getElementById("dl_link");
var links = ytm.document.getElementsByTagName('a');
var dl = links[1];
window.open(dl);});
ytm.close();
}
})();
提前致谢!