开发者

href to return nothing?

I have a user control in the modules folder of my project. and I have a link like Test in this control. When ever I mouseover this "Test" on the page, I can see the whole url like this "www.example.com\projectName\Modules". But I want to make it such a way that it shou开发者_如何学Gold display the url as "www.example.com\projectName". I want to get rid of that modules folder name.


I am assuming here you want to change the hover text that appears in the status bar?

To do some you could use the following inline script to do so:

<a href="http://www.google.com/somegarbage"
    onmouseover="window.status='http://www.google.com'; return true"
    onmouseout="window.status=''">Google</a>

This would produce a link with the text Google and when you hover over it the status bar text would show as http://www.google.com instead of the actual url which is http://www.google.com/somegarbage.

You can just change the code above to inject whatever you want by replacing the text being assigned in the onmouseover event.


By default the Href attribute will just append the current url. So if you're on a page like

http://abc.com/projects/index.htm

and in the html for this page you have

<a href="about/index.htm">link text</a>

Then the resulting url will be

http://abc.com/projects/about/index.htm

However, if you prefix the href with a / character, then it will make the link relative to the site root and it will give you what you're looking for.

<a href="/about/index.htm">link text</a>

will go to

http://abc.com/about/index.htm

So in your case....

Make your link like this..

<a href="/projectName">Test</a>


If you can set your <a> to runat server, you can do:

<a href="~/" runat="server">Test</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜