Is it possible to mask/ hide the lengthy URL and just to display the domain name alone?
Is it possible to mask/ hide the lengthy URL and just to display the domain name alone in address bar in the b开发者_JS百科rowsers like IE, Firefox, Chrome?
Please suggest.
Regards Gourav
You shouldn't do that.
It's against the very basics of the technology and usability.
Every page should have its unique address, letting users bookmark it, send link to a friend, navigate your site after all!
You want to use AJAX for this. In your index file, include a javascript file which uses XMLHttpRequest (or you can use something like jQuery.load if you don't want to go so low level) to load your content. With jQuery, you can do something like this:
<script type="text/javascript">
$(document).ready(function(){
$('a').click(function(event){
event.preventDefault();
$('#content').load($(this).attr('href'));
return false;
});
});
</script>
However, do not do so lightly - this can break search engine optimization and many other things as some people may have javascript off etc.
And remember, this is a very simplified example - you'd have to take care of things like external URIs (CSRF protection in browsers means you can't XMLHttpRequest another domain). Maybe you could add a CSS class called link_internal
and then add that in your jQuery selector etc.
domain = re.match(r'https?://(?:www\.)?([^/]+)', full_url).group(1)
This regex extracts the domain - without www.
but any other subdomains if they exist.
It uses the python re
module but it should be easy to adept it to another language.
精彩评论