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