书签:追加隐藏的iframe到页面并加载url [英] Bookmarklet: Append hidden iframe to page and load url
问题描述
我有一个用于重置路由器的小书签。
javascript:(function(){w = window.open( http://192.168.0.1/goform/formReboot, , 宽度= 1,高度= 1); self.focus();在window.onload = w.close();} )();
但它会在一个弹出窗口中打开。
我的新想法是动态地将隐藏的iframe添加到我正在使用JavaScript bookmaklet的页面中,然后在隐藏的iframe中打开url。这甚至是可能的吗?
我打开了一个更好的建议,说明如何做到这一点。
$ b $ pre $
(function() {
(new Image())。src =http://192.168.0.1/goform/formReboot;
})();
作为书签:
($ function)(){(new Image())。src =http://192.168.0.1/goform/formReboot;})());
或者,如果这不起作用,这里是您请求的'iframe'创建者:
(function(){
var i = document.createElement('iframe ');
i.style.display ='none';
i.onload = function(){i.parentNode.removeChild(i);};
i.src ='http ://192.168.0.1/goform/formReboot';
document.body.appendChild(i);
})();
I have a bookmarklet for resetting my router. I just need to visit and let the page finish loading, then my router starts resetting.
javascript:(function(){w=window.open("http://192.168.0.1/goform/formReboot","","width=1,height=1");self.focus();window.onload=w.close();})();
But it opens in a popup window.
My new idea is to dynamically append an hidden iframe to the page I'm on using a javascript bookmaklet, and then open the url in the hidden iframe. Is this even possible?
I'm open for better suggestion on how this can be done.
An even easier way would be to create a new IMG element:
(function(){
(new Image()).src = "http://192.168.0.1/goform/formReboot";
})();
As a bookmarklet:
javascript:void((function(){(new Image()).src = "http://192.168.0.1/goform/formReboot";})());
Or, if that doesn't work, here's the 'iframe' creator you requested:
(function(){
var i = document.createElement('iframe');
i.style.display = 'none';
i.onload = function() { i.parentNode.removeChild(i); };
i.src = 'http://192.168.0.1/goform/formReboot';
document.body.appendChild(i);
})();
这篇关于书签:追加隐藏的iframe到页面并加载url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!