Firefox addon: window.open, about:blank stays empty after winRef.document.write

Viewed 26

My extension is working in Chrome. I am currently porting it to Firefox.

When I click on an image I want it to open in a new window using the src of clicked image in an img tag.

In Chrome this works fine, in Firefox the new window opens as about:blank but stays empty even after I write html to it using document.write.

This is my working code for Chrome: content.js:

    $("img").click(function(){
        var s = $(this).attr("src");
        var hiddenImg = window.open("", "height=200,width=200");
        //style tag removes a blur filter in the new window
        hiddenImg.document.write('<img src="'+s+'"/><style>img{filter: none;}</style>');
        hiddenImg.document.close();
    });    

This is what I have tried for FireFox: content.js:

    $("img").click(function(){
        var s = $(this).attr("src");
        var hiddenImg = window.open("");
        hiddenImg.document.open();
        hiddenImg.document.write('<img src="'+s+'"/>');
        hiddenImg.document.close();
    });    
0 Answers
Related