You should be using some kind of custom made popups and dialogue like
http://umairj.com/27/how-to-create-simple-modal-dialogue-using-jquery/
http://www.jquery4u.com/windows/14-jquery-modal-dialog-boxes/
Jquery or Javascript alternative to window.open to get a different target
searching for an alternative to window.open without opening a window lol
Alternative zu window.open
Lightning Alternative of Window.Open() method ...
I have this function to ask for a basic password and then load a php script:
function passwd(){
var password = prompt('Enter the password');
if(password.toLowerCase() == "password"){
window.open("./files/restart-calibre.php")
}else{
alert("incorrect password!!");
}
}
As I am very new to this all of it is copied from stackoverflow.
Now this code does open the script in a new page which I do not want. What would be the best way to achieve this?
I have to open a PDF and ask to print it automatically. I did this:
const pdfWindow = window.open("generate_pdf.php?id="+id, "_blank");
if (!pdfWindow) {
alert("You have to enable popups");
} else {
pdfWindow.addEventListener("load", function () {
pdfWindow.print();
}, false);
}this is working correctly, window.open opens the link that output the PDF, then when the page loaded, it calls pdfWindow.print(); that open the dialog to print the PDF.
The problem is that browsers default have popup disabled. So most users will see "You have to enable popups" alert, because window.open will fails. I know popups can be easily enabled, but this is not nice for most users :(
Is there an other solution instead of window.open to open "generate_pdf.php", then, when "generate_pdf.php" generated the PDF, automatically ask to print it?
I used window.open because user should to remain on the main page.
Edit: sorry, language is Javascript. The reason why I have to automatically open the print dialog is because I want to be sure that operators will not forget to print the PDF, because they must to print it