URL masking in JavaScript

13,186

Things you could do:

1- Mask the external site in a html frame inside a document from your site. (for example www.mysite.com/shortUrl/)

2-Send a Location HTTP header (real url will eventually be displayed)

Keep in mind that browsers do their best to show the real address due to phishing concerns.

Share:
13,186
Michael Kniskern
Author by

Michael Kniskern

I am currently working as an IT engineer for the government of Mesa, Arizona USA

Updated on June 14, 2022

Comments

  • Michael Kniskern
    Michael Kniskern about 2 years

    I currently have the following JavaScript function that will take current URL and concatenate it to another site URL to route it to the appropriate feedback group:

    function sendFeedback() {
        url = window.location.href;
        newwin = window.open('http://www.anothersite.com/home/feedback/?s=' + url, 'Feedback');
    }
    

    Not sure if this is the proper terminology, but I want to mask the URL in the window.open statement to use the URL from the current window.

    How would I be able to mask the window.open URL with the original in JavaScript?

    • Michael Kniskern
      Michael Kniskern over 13 years
      @Assaf - Instead of displaying "anothersite.com/home/feedback/?s=www.mysite.com" in the new browser address bar, I want to display "www.mysite.com".
    • Šime Vidas
      Šime Vidas over 13 years
      From what I understand, you cannot manipulate the address bar of the browser window.
  • Michael Kniskern
    Michael Kniskern over 13 years
    Thanks for the input. I was looking for a quick and dirty solution in JavaScript, but it sound like more work than I really want to put into it.