6 Replies Latest reply on Jan 18, 2011 6:30 AM by 749371

    Using JS file with APEX


      I can't seem to be able to successfully link a JS file to an APEX template or page. I have followed the directions but but have had no luck. I have uploaded the JS file through "Shared Components>Static Files>Create" and have added "<script src=”#APP_IMAGES#custom.js” type=”text/javascript”></script>" to the HTML Header. I have also tried #WORKSPACE_IMAGES#, and #IMAGE_PREFIX# in place of #APP_IMAGES and still no luck. I have even tried a direct path " <script src="http://myserver.myport/my_images/custom.js"
      type="text/javascript"></script> " but this did not even work. The only thing that does work is to put the JavaScript directly into the Header of the page.

      Please suggest what else I could try.


        • 1. Re: Using JS file with APEX

          When you use one of those substitution strings, what does the reference look like in the resultant HTML page (what you see when you view the source of the page)?

          • 2. Re: Using JS file with APEX
            Hello Joel,

            Thank you for replying. Here is what I see when I view the source of the page when I use the three substitution strings:

            <script src=”#APP_IMAGES#custom2.js” type=”text/javascript”></script>

            <script src=”wwv_flow_file_mgr.get_file?p_security_group_id=715919280200643&p_flow_id=100&p_fname=custom2.js” type=”text/javascript”></script>

            <script src=”#WORKSPACE_IMAGES#custom2.js” type=”text/javascript”></script>

            <script src=”wwv_flow_file_mgr.get_file?p_security_group_id=715919280200643&p_fname=custom2.js” type=”text/javascript”></script>

            <script src=”#IMAGE_PREFIX#custom2.js” type=”text/javascript”></script>

            <script src=”/i/custom2.js” type=”text/javascript”></script>

            I hope that this gives you some information that is useful.


            • 3. Re: Using JS file with APEX
              Hi Linda,

              Thanks. Useful information.

              So in your browser, try to go to:


              (this assumes you're configured to use a Database Access Descriptor of 'apex').

              Do you get a file returned? Or does this result in an HTTP 404 File not found?

              • 4. Re: Using JS file with APEX
                Hi Linda & Joel,

                I have the same kind of problems in using a static Javascript file (hooked in to Static Files download ).

                My page template uses:
                &lt;SCRIPT LANGUAGE="JavaScript" SRC="#WORKSPACE_IMAGES#my_javascript.js" TYPE="text/javascript"&gt;&lt;/SCRIPT&gt;
                &lt;link rel="stylesheet" href="#WORKSPACE_IMAGES#my_css.css" type="text/css" /&gt;

                works fine.

                returns 'Access Denied'

                returns a blank page (as expected)

                What can we do now?

                Best regards,

                • 5. Re: Using JS file with APEX
                  Hi again,

                  Finally solved this problem!!

                  What was happened (in my case):
                  - We had 4 different applications, all having their own copy of the Javascript having the same file name.
                  - Apex Builder failed to manage them separately (see other thread).
                  - Removed all copies and uploaded a global workspace version.
                  - Only the last application that had removed its own copy now worked with the global version??
                  - Joel's test (see above) pointed out some access problems: 'Access Denied'
                  - Removed the Javascript form Static Files (no files left).
                  - Uploaded the Javascript under Cascading Style Sheets.
                  - Still got 'Access Denied' in test.
                  - Replaced the Javascript using a different file name.
                  - OK, that worked.
                  - Moved the Javascript back to the Static Files
                  - OK, it keeps working.
                  - Replaced the Javascript using its original file name.
                  - OK, it now works as it expected to work in the initial set up?!?!

                  So it seems that Apex Builder has problems in its administration when maintaining metadata and content of Static Files.
                  The file should be completely removed, before you can reintroduce it with different metadata.
                  NOTE: some problems do NOT occur when applications are run in Apex Builder!

                  Hope this can be reproduced by the Apex team for fixing it.

                  • 6. Re: Using JS file with APEX
                    I am using Apex 4.0.2. I have uploaded js file into Home->Application Builder->Application 108->Shared Components->Static Files foder. Finally i put this bellow line my page on 'HTML Header and Body Attribute' & its working fine.

                    <script src="#APP_IMAGES#jquery.js" type="text/javascript"></script>

                    WIsh yours good luck.