BookmarkSubscribeRSS Feed
mathias
Quartz | Level 8

Hello,

 

I'm execting a STP in a new from my main web page.

<form target="_blank" action="http://<UrlToMySTP>" method="get" enctype="multipart/form-data">

And I would like it to close automatically when it's done.

I tried to do this in JavaScript, 

data _null_;
    file _webout;
    put '<HTML>';
    put '   <HEAD>';
    put '   </HEAD>';
    put '   <BODY onLoad="window.close()">';
    put '   </BODY>';
    put '</HTML>';
    run;

but the browsers don't allow that (security vulnerability)

Scripts may close only the windows that were opened by it.

 

Is there another way to close the page?

Thanks!

7 REPLIES 7
Vince_SAS
Rhodochrosite | Level 12

Can you explain why you want to do that or what you're trying to achieve?  There may be a different way to get the result that you need.

 

Vince DelGobbo

SAS R&D

mathias
Quartz | Level 8

When a button is clicked, something needs to be done in SAS, (for example delete a record in a table).

and that just needs to be done in a separate window

that window is empty is empty and doesn't need to stay open.

I wan to avoid the user having to close the empty window manually.

 

On another case I used a redirect, because I could afford a page refresh, not this time.

 

I found a way to just call the STP with ajax. But that was more difficult than I thought necessary.

AllanBowe
Barite | Level 11

It is MUCH easier, and far better practice, to build web applications on SAS using AJAX and dedicated html / javascript than to try and build your web logic using put statements in a data step!

 

The process is also far easier given the availability of the Boemska open source h54s adapter.  I did a post some time ago explaining how to use the adapter, and an SGF paper here.

 

The short story - build and deploy your web application logic (html/css/javascript) to the SAS Web Server, and your data step / backend logic (sas programs) to the SAS Application server.  This will save a huge amount of trouble as your application complexity increases.

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
mathias
Quartz | Level 8

Yup! I have heard of it numerous times, even tried it.
But this tool requires the sas server and the web server to be on the same domain or server.
Which is never the case in my setups.
So I can't use h54s.

AllanBowe
Barite | Level 11

The tool doesn't require it..  Your SAS server is configured to require it.  You will have the same issue regardless of whether the adapter is used or not, if building web apps on SAS using ajax.

 

 

If your site does not permit your web files to be served from the SAS Web server, you can always ask for your preferred web server to be whitelisted.   And use chrome with CORS disabled in the meantime.  This approach is taken by many of our clients.  It is far preferable to do these things properly than to have to maintain a web application composed of put statements / proc stream / whatever...

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
mathias
Quartz | Level 8

You don't have CORS issues when using "jsonp", no need to whitelist the webserver on the sasserver.

(at least I don't, maybe it's different on different setups)

 

And the put statements that write an empty html page are very little in this case.

 

boemskats
Lapis Lazuli | Level 10

Hi Mathias,

 

The thing with JSONP is that you can't make POST requests, which means you're limited to simple URL-encoded parameter values when sending data to SAS. It's also... a bit of a hack. 

 

I'm not a fan of it, but I'll have a chat to our devs and see if there's a way we can implement it as an optional transport mechanism. Will keep you posted.

 

Nik

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1722 views
  • 3 likes
  • 4 in conversation