Why does the favicon not display in the new Window created by the Print Button?

Why does the favicon not display in the new Window created by the Print Button?

FurburgerFurburger Posts: 37Questions: 8Answers: 0

When the Print button's action is called, it opens a new about:blank Window and displays the report.

Although the favicon (and all the css) is copied to the head of the new Window, for some reason the favicon is not displayed in the new Window:

<head>
<title>Report Title Here</title>
<link rel="icon" type="image/png" href="https://example.com/img/favicon.png">

I am using Chrome and haven't tested it on other browsers.

Is it a browser thing because it is an about:blank Window or is there some other issue?

Any idea how to resolve this because the new Window looks very bare and would be so much nicer if it had the same favicon as the website.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    about:blank Window or is there some other issue?

    Essentially exactly that. It just uses window.open and writes the HTML straight into the new window, so it doesn't have a url base from which the browser can go and get the favicon. Interestingly it appears Firefox does, so it must inherit from the parent, but Chrome does not.

    What you could do is use the customize callback of the print button to insert the favicon HTML into the new document:

    <link rel="shortcut icon" type="image/png" href="http://example.com/favicon.png"/>
    

    Regards,
    Allan

  • FurburgerFurburger Posts: 37Questions: 8Answers: 0

    Hi Alan

    Thanks for the prompt reply.

    I see you have answered 7323 questions so I do appreciate it.

    I am not too sure what you mean about inserting the favicon into the new document because it is already there. Your code already copies all links including the favicon.

    The HTML I copied into my original question is taken from the new window. The favicon is there along with the CSS link.

    It is odd that the Browser can read the CSS file but not the favicon URI.

    It may just be a Chrome thing so no stress - I was just interested to see if you had a workaround.

    Maybe Chrome will fix it in future versions.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @Furburger ,

    Yep, it's definitely a Chrome issue as it works as expected on Firefox. I did find this SO thread here, which suggests a different way to launch the window for Chrome. I'm not sure if that would be helpful at all.

    Cheers,

    Colin

  • FurburgerFurburger Posts: 37Questions: 8Answers: 0

    Hi Alan

    Thanks for the link. I tried it out but it doesn't work unfortunately. I dug a bit deeper and found out it is actually a Chrome thing. On chromium.org they say they have blocked this because:

    data: URLs are generally a source of confusion for users. Because of their unfamiliarity and ability to encode arbitrary untrusted content in a URL, they are widely being used in spoofing and phishing attacks.

    It kinda makes sense...

    But thanks anyway. I will live without the favicon for now.

This discussion has been closed.