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 4585536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:30:33+00:00 2026-05-21T21:30:33+00:00

I am embedding a external js file on some domains and I need to

  • 0

I am embedding a external js file on some domains and I need to get the current location of the their URL to send to the server before the script is rendered and not after. I need to this dynamically so I cannot have the user specify the url themselves. For example I have a script:

<script type="text/javascript" src="file.js?url=NEED THIS"></script>

I would love to simply replace NEED THIS with window.location.href, however sadly this would not work. The main problem is that I need to get the url and parse it on the server side to generate the content file.js will deliver so I need this url passed to file.js at the beginning. How can I achieve this without using a iframe?

  • 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-21T21:30:34+00:00Added an answer on May 21, 2026 at 9:30 pm

    Use a JavaScript to document.write an appropriate script tag!

    <script>
        document.write('<scr'+'ipt src="file.js?url=' + encodeURIComponent(location.href) + '"></scr'+'ipt>');
    </script>
    

    Doing it this way, your users could still specify their own URL simply by putting the written script tag on the page instead of the above.

    If you don’t want this, you need to check for location.href in your JavaScript file.

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

Sidebar

Related Questions

My code is an external .as file. Google provides this code on their demo
I am embedding images into my assembly using .resx files. Upon runtime, I need
I'm embedding Jetty in a Spring based application. I configure my Jetty server in
Hi I am developing an ASP.net web application. I need to find the current
The problem: I am embedding a CSS file into a custom control library with
I am embedding IronPython in a C# program. I understand that I need to
How to export embedded video from powerpoint 2010 to external file programmatically using MS
I'm having a surprisingly difficult time embedding variables with quotes to an external command
I am embedding a audio file and having a issue. When accessing the page
I have some video embedding code generated for one of the videos on a

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.