From a form in a web page, I'm opening a stored process (STP) in a new window.
<form target="_blank" action="http://<UrlToMySTP>" method="get" enctype="multipart/form-data">
that STP does someting and when it's done I need to close it's window. So I tried to close it with javascript like this
data _null_;
file _webout;
put '<HTML>';
put ' <HEAD>';
put ' </HEAD>';
put ' <BODY onLoad="window.close()">';
put ' </BODY>';
put '</HTML>';
run;
but I get an error message that says:
Scripts may close only the windows that were opened by it
I cannot find any solution for this. Is is possible to circumvent the problem to get to the same result ?
You can try ajax query with
dataType: "jsonp"
. Its can overcome CORS. STP must return json response, wrapped by name of js function, that wiil be executed in browser after ajax response.Example
json_test.sas
html_test.html
Must contain:
Make your attention to additional param
callback=
in url .And
You also if you use EG to cretae stored process, you must exclude Stored Process macros from STP settings and set result capabilities to Stream.