How can Request.UrlReferrer be configured using client-side JavaScript? If it can be done, what is the process?

In my application, I heavily rely on Request.UrlReferrer to handle link clicks and maintain a page history for users.

Due to new requirements, I now need to navigate to a specific location using <input type="button" /> instead of <a href="mypage.aspx"/>

I am currently experimenting with the following code:

<input type="button" 
onclick='ShowLoadingScreen();document.write("<a id=\"link\" style=\"display:none;\" href=\"mypage.aspx\">link</a>");document.getElementById("link").click();'>
Do Thing
</input>

However, this code is not very clean and writing to the document removes my loading screen. Changing the innerHTML of an element also causes issues with clicking.

According to the Microsoft Documentation

Clients can falsify or choose not to present a Referer header. Therefore, while the UrlReferrer property can be useful for identifying basic trends in Web traffic; you should not use it as part of an authorization scheme to control access to data.

It is possible for the UrlReferrer to be falsified, which would be beneficial for my purposes. However, I do not know how to achieve this.

Is there a way to fake the UrlReferrer using JavaScript to keep my code minimal?

<input type="button" 
onclick='ShowLoadingScreen(); SetUrlReferrer(); window.location="mypage.aspx";'>
Do Thing
</input>

Unfortunately, this approach does not work:

document.referrer = 'myref.aspx';

Error: Object doesn't support this action

Answer №1

My apologies, however I do not believe that it will be successful. The only way for this to work is if you manually construct the HTTP request (even with AJAX, there may still be issues on many browsers).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Step-by-step guide on adding an ASP button that will show additional textboxes when activated

My goal is to allow users to add more information to a webform by clicking a button to reveal an additional text box. Currently, I have 3 textboxes and buttons in my implementation with only the first one visible. The idea is to track which textbox should ...

What is the best way to implement a transaction fee when a specific function is triggered within my contract?

Consider this scenario: whenever a user successfully performs a contract function that calculates the sum of two numbers, I want to impose a 1% ETH fee that is transferred to a separate account from the contract. Although my current method "works", it is n ...

How to Create a DataTable Responsive Feature Where All Columns Collapse on Click, Except the Last One?

I am currently utilizing the DataTables library to generate a responsive table. I am aiming to create a feature where all columns in the DataTable can toggle between collapse and expand states when clicked, with the exception of the last column. Below is a ...

Using d3.js to dynamically change the color of svg elements based on their data values

I was searching for a way to dynamically color SVG rectangles based on values from a dataset. If I were to create rectangles for each data entry, how could I adjust the rectangle's color according to the data value? Here is what I currently have: // ...

Tips on automatically reconnecting to a lost connection using Linq to SQL

Is there a way to automatically handle lost or timed out connections without having to wrap every call in a try-catch block? Is there an event I can subscribe to for connection issues, or is there a way to avoid checking every LINQ query? If not, why has ...

Navigate to a different subdomain and place a cookie on the newly redirected subdomain

The version of Express is 4.x NodeJS is running on version 12.x At a.example.com, I have a listener for the GET method that redirects to b.example.com and sets a cookie on b.example.com. app.get('/foo', (req, res) => { res.cookie(' ...

How can I add multiple filters to a Kendo Grid?

Is there a way to include two separate filter fields for date filtering in Kendo Grid UI? Currently, the method I am using only allows for one date filter to be displayed. filterable: { ui: function (element: any) { element.ken ...

Tips for combining enable and disable properties in flatpickr.js?

I'm facing a challenge with using both the enable and disable properties in flatpickr.js. The enable property returns a range of dates that should be enabled, but I specifically want to disable certain days within that range, like weekends. datePicker ...

Ways to incorporate a dynamic value into a chart created with chart.js?

I want to create a doughnut chart representing the number of individuals who have tested positive for Coronavirus and the number of deaths related to it. How can I transfer the same data from the top container into the chart? The confirmedCases and deaths ...

Using NodeJS to facilitate communication between multiple NodeJS instances while also overseeing operations of a Minecraft server

I have a question about communicating between NodeJS instances. Let's say I have one NodeJS instance running a chat room - how can I access that chat and see who is connected from another NodeJS instance? Additionally, I'm curious if it's f ...

Differentiating Between Observables and Callbacks

Although I have experience in Javascript, my knowledge of Angular 2 and Observables is limited. While researching Observables, I noticed similarities to callbacks but couldn't find any direct comparisons between the two. Google provided insights into ...

I made a mistake with my git repository. Should I try to fix it or just start fresh?

After spending months learning web development, I recently completed my first project. Unfortunately, right before deployment, I made a mistake with my backend git tree. I attempted to resolve the issue using suggestions from other resources, but none of ...

Error: JSDOM - The document variable has not been declared

After creating a basic webpage that displays a single message, I decided to experiment with JSDOM and encountered an error. Despite researching online examples and Stack Overflow questions, I have struggled to resolve even the most straightforward scenario ...

Is there a way to retrieve the value of a dropped file in a file input using jQuery?

Can the data from a dropped file be set in a file upload input field? Or does a dropped file need to be instantly uploaded to the server? Here is an example code snippet: <input type="file" id="drop-box" /> $("#drop-box").on('drop', fun ...

Exploring how Node.js, Express.js, and Mongoose work together to handle

I am experiencing difficulties with handling data received from APIs, as it returns null and doesn't wait even though I have used async/await functions. My goal is to retrieve data from the first URL, then gather data from other URLs based on the res ...

Post Request to Express API does not produce any output

Today, I encountered an issue while trying to create a JWT authentication API in Express. When I send a POST request with Postman, it only returns {}. Below is the code for server.js: const express = require("express"); const mongoose = require("mongoos ...

The validation of form.$invalid appears to be malfunctioning when using the Angular UI date picker

There are two fields on the form, one for selecting a due date and another for entering a number. The due date field is a date picker where you can choose a date or manually enter a number to set the date. The create button gets enabled only when setting ...

Attempting to retrieve exclusively the checked records in Vue.js

Currently, I am referring to this library for checkboxes. As I delve into the code, I notice how it is declared and utilized. Initially within the el-table, we have @selection-change="handleSelectionChange". They have initialized an empty array ...

Should I refrain from storing user files on my server?

Greetings! I am currently working on an Express js + React js application and using MySQL for database management. I have successfully stored user information like email, hashed passwords, and user IDs in the database. However, now I want to create ...

Troubleshooting error handling in Node.js using Express and MongoDB

hey there, I'm new to Node.js and I'm working on creating a basic notes app using express and MongoDB. However, I'm encountering an issue when trying to update a note which displays "Cannot PUT" followed by the note's ID. Below is the ...