javascript - How to avoid "The operation is insecure" error when accesing opened window -
i'm trying open new window , fill data ready copyed in clipboard, printed or saved hard drive. i'm doing through greasemonkey user script.
simplified version of script:
window.addeventlistener("load", function() { /*export data*/ //create button var button = document.createelement("input"); //call actual export function button.onclick = function() {window.exportujrozvrh();}; //i tried this: //button.onclick = (function() {window.exportujrozvrh();}).bind(window); button.value = "print data in new tab"; button.type = "button"; //append button node getelementbyxpath(tisk_path).appendchild(button); }); window.exportujrozvrh = function() { //create new tab (or window if tab not supported) var okno = window.open(); //no url should fine same origin policy, shouldn't it? //check if popup exists if(okno==null) alert("popup blocked."); //write data okno.document.open(); okno.document.write("data"); okno.document.close(); }
if run button
function throws following error:
securityerror: operation insecure.
however, if function lauhced debug console or url bar (by typping 1) script works properly.javascript: window.exportujrozvrh();void(0)
)
guess it's context function launched in matters. why trying use .bind(window)
.
1) calling throws "window not defined" error. i'm quite used fact window defined, gave up.
Comments
Post a Comment