Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
Javascript - change filename in Print - Save dialog

I am using frame to load PDF. when Print action is given using javascript and clicked save option in Print Page, it shows default filename in filesavedialog which is nothing but method name from URL. I have to set different file name in Print save dialog.

Print save as dialog option shows - EmployeeReport as filename. but I have to show empid as filename in print savedialog.

I am using below code to print document in frame -

setTimeout(function () {
            $('#printFrame').attr('src', "/Employee/EmployeeReport?id=" + empid);
            
            
            $('#printFrame').load(function () {
                window.frames['frm'].focus();
                window.frames['frm'].print();
                
            });
            
        }, 500);

I also tried using changing title of document to empid but it still shows default file name which is nothing but url.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are going in the right direction. You need to set the document title but you may have to play a little bit in the browser console to find the correct way. You can try setting the document title as shown below and see if works.

setTimeout(function () {
        $('#printFrame').attr('src', "/Employee/EmployeeReport?id=" + empid);
        
        
        $('#printFrame').load(function () {
            window.frames['frm'].document.title = empid; 
            //OR
            //document.title = empid;
            
            window.frames['frm'].focus();
            window.frames['frm'].print();
            
        });
        
    }, 500);

The above approach should work.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda