Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6088011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:56:10+00:00 2026-05-23T11:56:10+00:00

I have javascript file, located on one domain, e.g: http://mydomain.com/script.js Some pages (from other

  • 0

I have javascript file, located on one domain, e.g:
http://mydomain.com/script.js

Some pages (from other domains) include my javascript using SCRIPT tag. They can include it via http or https

<script src="http://mydomain.com/script.js"></script>
or
<script src="https://mydomain.com/script.js"></script>

Also they can include my script using 3rdparty iframes, e.g:

<iframe src="http://3rdparty.com/frame.php">

where http://3rdparty.com/frame.php outputs

<script src="http://mydomain.com/script.js"></script>
or
<script src="https://mydomain.com/script.js"></script>

I can edit only static javascript file script.js on mydomain.com.

How I can detect what protocol used to load my javascript (https://mydomain.com/script.js or http://mydomain.com/script.js)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:56:10+00:00Added an answer on May 23, 2026 at 11:56 am

    I do not believe that you have any ability to identify within the code how it has been loaded. The best suggestion I can come up with is to have the http and https point to different locations ( i.e. be different sites ) and have something within the code that indicates which one is being picked up.

    var protocol=’http’

    or

    var protocol=’https’

    It does mean maintaining two files, and two sites though.

    ETA: I thought James Wiseman had the answer, but of course that will only return the protocol of the PAGE, not the SCRIPT. If you know these are related, that would work ( often the https is loaded on https pages and vv ). But it is not definitive.

    It is a good solution if you can be confident that the protocol on hte page is the same as on the script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a properties file located in my server. Using Javascript or any other
For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file
I have this countdown script wrapped as an object located in a separate file
I have this javascript code (the function SHA-1 is located in an external file):
I have a javascript file that I reference in HTML with standard <script src=foo.js?param></script>
We have a web site in the domain, let's name: http://website.com . It is
I have a javascript file that reads another file which may contain javascript fragments
I have a JavaScript file which is loaded up at the end of my
I have a javascript file main.js and five html files 1.html,2.html,3.html,4.html,5.html I want to
I have an external Javascript file and i am trying to alert the value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.