We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

How to refer relative path in JavaScript?

miyahira
miyahira asked
on
Medium Priority
1,179 Views
Last Modified: 2008-01-09
Instead of :
location.href="http://192.168.200.5/MyWebCarpet/wf_Form01.aspx"

is there any way to refer a relative path ?
Something like:
location.href="/MyWebCarpet/wf_Form01.aspx"
or
location.href=Server.MapPath("/MyWebCarpet/wf_Form01.aspx")
Comment
Watch Question

ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
the first one is good:
window.location.href="/MyWebCarpet/wf_Form01.aspx"

Because window is root object you can ommit it.

Systems architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
Sorry, the quoted word should read "realm" and not "real"

Author

Commented:
Thank you very much, Zvonko
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
You are welcome.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.