function ask_email() {
const url = email_pdf_new.php?f=" + fnue
fetch(url)
.then(() => {
const final = steps
? "choose_property_us.php"
: "choos_property.php";
window.location = final + "?prop=" + fname;
})
}
What we are doing in the above is using the Browser fetch() function to make an AJAX call back to the server to send the email - the window is redirected only after this has completed.open(location, '_self').close();
<!DOCTYPE html>
<html>
<head>
<title>Print Single Form</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<title>Backflow Assembly & Test Report Form</title>
<style>
.nopadding {
padding: 0 !important;
margin: 0 !important;
}
.wrapper {
max-width: 767px;
min-width: 480px;
margin: 0 auto;
}
</style>
</head>
<body>
<script>
<?php
//open the pdf win
print 'window.open("' . $loc . $fname '")';
// check step
if ($_SESSION['use_steps']) {
// maybe use a JS setTimeout to open to change location to give time to the PDF to open
print 'window.location = "choose_property_us.php?prop=' . $fname . ';';
} else {
// maybe use a JS setTimeout to open to change location to give time to the PDF to open
print 'window.location = "choose_property.php?prop=' . $fname . ';';
}
// send email without asking permission
include_once "email_pdf_new.php"; // you should use/read $fnue inside
?>
</script>
</body>
</html>
ASKER
his method can only be called on windows that were opened by a script using the Window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.
ASKER
ASKER
ASKER
ASKER
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
ASKER
<!DOCTYPE html>
<html>
<head>
<title>Print Single Form</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<title>Backflow Assembly & Test Report Form</title>
<style>
.nopadding {
padding: 0 !important;
margin: 0 !important;
}
.wrapper {
max-width: 767px;
min-width: 480px;
margin: 0 auto;
}
</style>