-1

I know that there's a meta tag to change the page's resources' incompleted URLs. For example: If I were to load a JS file using a <script> tag to get the file main.js, then the page would auto-complete the src from "./main.js" to "https://example.com/main.js"

<!-- This file is hosted on https://example.com -->
<script src="./main.js"></script><!-- will load https://example.com/main.js -->

But when you add the meta tag that I've talked about previously and set it to auto-complete with "https://example2.com" and tried to load the same JS file in "https://example.com" the website would load the file from "https://example2.com"

<!-- This file is hosted on https://example.com -->
<meta name="..." url="https://example2.com">
<script src="./main.js"></script><!-- will load https://example2.com/main.js -->

What's the name of that meta tag? And, if what I said wasn't true, is there any other way to achieve the same behavior?

Adel Sbeh
  • 3
  • 4

1 Answers1

0

I don't think that a meta tag like this exists. It's less that the browser 'auto-completes' links, but more that it converts relative links to absolute ones to display them in the console.

Usually, accessing scripts from another domain is quite rare, by which I mean it only occurs once or twice on a page. For only a few instances, I would just use the full URL https://example2.com in my src attributes.

If you needed the domain to remain variable, or have very many instances of it, you could use PHP. At the top of your page, specify a variable $sourceURL:

<?php $sourceURL = 'https://example2.com' ?>

And then reference this variable in your src attributes, eg. :

<script src="<?php echo($sourceURL) ?>/main.js"></script>
Run_Script
  • 2,487
  • 2
  • 15
  • 30