how to set relative url for window.open and hyperlink

T

tomek.romanowski

Hi !

I have a problem with defining a relative url, which is one of
parameters of window.open call.
Here is the situation:

1. "Parent" page called 2000 is in subfolder of my app, the subfolder
is called Z.
2. On the 2000 page there is an asp hyperlink, which should open new
window with 2010 page. But since the window can't have browser menu
etc. I set onclick attribute with window.open command instead of
NavigateUrl property.
3. The 2010 page is also located in Z subfolder.
4. As an url of hyperlink I set /Z/2010.aspx
I tried also ~/Z/2010/aspx but it never worked.
5. Everything works fine when my app is run against Visual Studio
build in server. I mean the 2010 page opens in new browser window when
hyperlink is clicked, opens under url
http://localhost:2554/Z/2010.aspx page

6. The above doesn't work when app is deployed on IIS. Browser
attempts to open
http://localhost/Z/2010.aspx page
while it should be
http://localhost/MyApp/Z/2010.aspx.

What is wrong ?
 
T

tomek.romanowski

I found solution for that: the url which is passed to window.open must
be full url.
To get "prefix" I call
this.ResolveClientUrl("~/Z/2010.aspx")
and tylda character (~) is replaced automatically as needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top