Hello everyone,
I created a form in SAS Viya V.03.05 using Job Execution (Studio), but when I place the style.css and script.js files separate from the HTML code, neither of them work.
Even using a library like Bootstrap does not work.
Am I doing something wrong, or does SAS not execute files outside the form?
I tried the following methods:
/SASJobExecution/?_program=/Public/JES/script.js /SASJobExecution/?_program=/Public/JES/style.css
<link href="/SASJobExecution/?_program=/Public/JES/style.css" type="text/css" rel="stylesheet"> <link href="style.css" type="text/css" rel="stylesheet">
<script src="/SASJobExecution/?_program=/Public/JES/script.js"></script> <script src="script.js"></script>
Could someone please help me?
DeMer, thanks for your help. You gave me more determination to keep insisting. And I did it.
I still don't know why, but the problem occurs that the .css file needs to have the <style></style> tag in the file. Example:
<style> body { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; background-color: #181c35; font-family: Arial, sans-serif; } /* Your CSS styles */ </style>
This way, the link created from the SASDrive URI recognizes as CSS:
<link href="/files/files/########/content" type="text/css" rel="stylesheet">
Thanks guys for all the support!
Have you tried this:
<link href="/Public/JES/style.css" type="text/css" rel="stylesheet">
No, it doesn't work either. I had already tried that.
You must place the stylesheet and scriptfile in a location from where the web server (apache/httpd, not the web application server) can serve them, and use the corresponding web path as your href. Keep in mind that the browser is the place where everything has to come together.
when I place the style.css and script.js files separate from the HTML code, neither of them work.
If that's an HTML page with existing css and js files, have you tried adding the file path?
<link href="/Public/JES/style.css" type="text/css" rel="stylesheet">
No, it's not an .html file, but rather HTML written in the 'HTML form'. Do I need to create an HTML file and "link" to it?
Check out the section "Including a File in an HTML Form" in
https://documentation.sas.com/api/docsets/jobexecug/v_002/content/jobexecug.pdf?locale=en
See if it works in V3.5.
I tried to put everything in 'Including a File in an HTML Form', but it still didn't work
Was there anything in the browser F12 console log?
Yes, it shows this error. But I don't know what this MIME is.
Means that the CSS file has been stored in the File Service with a content type that is not text/css.
I think the easiest way in V3.5 is to import the files using SAS Drive. It will set the MIME type based on the file type in the file name e.g. myfile.css.
I tried every way, with and without the extension name; putting '/SASJobExecution?_FILE=/Public/JES/style.css'; '/SASJobExecution?_FILE=/Public/JES/style'; 'files/files/4341684f-d65e-4760-af63-5b8123b0a370/content'', but I couldn't find it in any of them...
The strangest thing is that SAS recognizes the file format, but it still gives this type of error.
Can you see the file characteristics in a browser with a URL like
http://yoursystem/files/files/4341684f-d65e-4760-af63-5b8123b0a370
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.