![]() | ![]() | ![]() | ![]() |
There is not a way to password protect an HTML file created by ODS HTML alone. Password protecting HTML files would usually require the use of a CGI. You can apply some simple JavaScript to an HTML page prevents unwanted viewers from getting to the page, but it is not totally secure. The Prompt dialog box is used to get input from the user regarding the password. The password is set on line 3 of the example code below. If the password is entered correctly, a dialog box is displayed along with the page. If the password is entered incorrectly, a dialog box is displayed and the viewer is referred to another page by the window.location window object.
In the example below, the JavaScript is placed in a separate file which makes the password information more difficult to access. You can store the password file and the error file as relative or absolute paths. If this is stored as a relative path, then they would need to be in the same location as the HTML file created. View output, the JavaScript page, or the error page.
// Add this JavaScript code to a file: var password = prompt("Enter your password",""); if (password == "templateFAQ") { alert("Password accepted! Loading page..."); } else { alert("" +password+ " is an Invalid Password! Access denied..."); //window.location specifies the file that loads when //the user enters an incorrect password: window.location="error.html"; } //***********End of JavaScript file****************** proc template; define style styles.test; parent=styles.default; style body from body / prehtml='<SCRIPT LANGUAGE=JAVASCRIPT TYPE="text/javascript" SRC="password.js" ></script>'; end; run; ods html body='temp.html' style=styles.test; proc print data=sashelp.class; title; run; ods html close;
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | Base SAS | All | n/a |