My goal is to direct the user from one web page to another that requires a password for access. The user arrives on the initial page by scanning a barcode with a specific terminal, similar to a smartphone equipped with a customized barcode reader application that includes user and password data in its output.
For example: When the user scans a barcode linked to , the application appends the user and password before redirecting the user to the correct page: https://bob:[email protected]/redir.html
What I aim to do is transfer 'bob' and 'redpRrot93' to the destination page where the redirection occurs. For instance: https://bob:[email protected]/pages/destination.html
I have tested this code and can confirm it works:
<script>
function redirectToContent(){
if (location.protocol == "https:"){
window.location='https\x3A\x2F\x2Fspock:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="61170e13130408170e0d0013045452211616164f0c0802130e0f4c040f06080f040413080f064f0610">[email protected]</a>/ppages/404.html';
}
else {
window.location='http\x3A\x2F\x2Fspock:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5d2b322f2f38342b32313c2f38686e1d2a2a2a7330343e2f32337038333a343338382f34333a733a2c">[email protected]</a>/ppages/404.html';
}
}
</script>
However, I encountered difficulties finding a straightforward way to pass user and password information from the redir page.
This is the updated (and functioning) code snippet:
<script>
function redirectToContent(){
let username = "spock";
let password = "vorreivolare53";
// consider using template string literals with backticks ``
// window.location = `https://mywebsite/${username}/${password}`;
if (location.protocol == "https:"){
window.location=`https\x3A\x2F\x2F${username}:${password}@www.micron-engineering.gq/ppages/404.html`;
}
else {
window.location=`http\x3A\x2F\x2F${username}:${password}@www.micron-engineering.gq/ppages/404.html`;
}
}
</script>