-3

I want to create an html file that I can use as a link that will (eventually) redirect to the requesting URI.

I can hard code the redirect target to be the caller, but I'd rather not.

Update: As for what I will use to do it, the following comment provides a starting point:

from https://stackoverflow.com/users/665261/billy-moon

on Redirect from an HTML page:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=http://example.com">
        <script type="text/javascript">
            window.location.href = "http://example.com"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
        If you are not redirected automatically, follow the <a href='http://example.com'>link to example</a>
    </body>
</html>

This will not work unless I'm willing to replace the 'http://www.example.com' with my calling page similarly in a hard-coded fashion.

Unless, there is a way to redirect to the calling URI, programmatically.

This will be a client side redirect. I don't have knowledge of the web server that my company uses and it cannot be assumed since this will be placed in production if it works. My html will be static.

Aside: The goal is to provide a link that once requested calls a third-party API, then redirects to the calling URI. (I do not have connectivity to the third-party API yet, so figuring that out is not part of the question.) Doing something in the interim, after the html has loaded, but prior to the redirect (such as calling the API/making a command-line terminal call against a scheduler) is desired, however.

But to be clear, my question is 'How do I redirect to the calling URI within an html file?'

Community
  • 1
  • 1
jetimms
  • 417
  • 1
  • 5
  • 23

1 Answers1

1

use the meta tag refresh

see: http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-meta-refresh.phtml

example:

<META http-equiv="refresh" content="0;URL=http://www.example.com">
DrCord
  • 3,917
  • 3
  • 34
  • 47
  • yes, you obviously need to change example.com to the URL you want to redirect to... – DrCord May 05 '15 at 16:34
  • I guess that's the question. How do I redirect to the calling page, programmatically? Any ideas? Thanks! – jetimms May 05 '15 at 17:35
  • HTML is not a programatic language it is a markup language, so you cannot. You would need to use JavaScript or another programatic language. – DrCord May 05 '15 at 17:37