0

I have a simple javascript question (I'm not a javascript expert, so excuse me for this simple question ;). We are currently migrating a system and on the old system there should be a simple HTML-link which directs you to the new system (with the same path). My current approach doesn't not work really well:

Information can be found<a href="javascript:'('http://theNewServername:8080/'+(window.location.pathname));">here </a>

This doesn't represent me the right href-link. Can you help me with this 'one-liner'?

1 Answer 1

2

Like this?

<a href="javascript:void(window.location.href='http://theNewServername:8080/'+(window.location.hostname))">here </a>
Sign up to request clarification or add additional context in comments.

3 Comments

I imagine Op probably wants window.location.pathname though ... no?
I just corrected what I saw... the pathname on the new server is the hostname of the current one.
yes, right. I wanted pathname. I edited it above. It works :-) Thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.