Results 1 to 2 of 2

Thread: Single .js file for all the pages.

  1. #1
    Join Date
    Sep 2014
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Single .js file for all the pages.

    Hi Frnds,

    I have small query.

    I have single JS file and i uploaded it in a specific location.

    Now i need to call this js file into the pages. But don't want to insert the each and every time into the page. I need to make it dynamic calling from server.

    I got idea but i don't know how to do that (or) whether it is possible or not.

    Idea: I need to create one xyz.js file, in this xyz.js i need to call another abc.js which i uploaded in specific location. Now i wil inser xyz.js path into the page(main template).

    if i changed anythig in abc.js, it will automatically updated in all the pages. In future i won't get any problem.

    guys if you didn't understand my issue please let me know i will give example.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Without specifics, I would recommend simplifying the situation by just using the absolute path to this external .js file, ex (you will want to use https on an ssl if this or the pages it's on are or need to be secure):

    Code:
    <script type="text/javascript" src="http://www.somedomain.com/scripts/abc.js"></script>
    Put that in the head of each page, or better still, if you have a server side template, or head include, put it in there.

    If it will always be on the same domain as your pages, the network path is preferable:

    Code:
    <script type="text/javascript" src="/scripts/abc.js"></script>
    That way either protocol (if available) will be used as necessary.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Single JS file
    By Aravona in forum JavaScript
    Replies: 6
    Last Post: 05-24-2011, 07:35 AM
  2. Replies: 0
    Last Post: 08-07-2009, 05:57 AM
  3. Replies: 4
    Last Post: 04-15-2009, 02:27 AM
  4. Single Selection from PHP File
    By Diversions in forum PHP
    Replies: 2
    Last Post: 09-07-2008, 03:30 PM
  5. Replies: 4
    Last Post: 08-02-2007, 03:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •