Hidden the web address of the status bar

xiaoxiao2021-03-06  93

Introduction

When you move your mouse pointer on any of the link in the browser, the corresponding hyperlink is shown in the status bar. As a webmaster or developer of a web site, many times you want to hide such hyperlinks in your pages. This is needed frequently in download pages to hide the original content location or payment related pages. in this small code sample we will use ASP.NET HyperLink web control to display our links and then write code to hide them from the site visitors.

The code

As an example let us assume that you have a HyperLink control called HyperLink1 on the web form When that control is rendered in the browser;. It gets converted into an HTML tag In order to hide the URL from the end user we. Need to Handle Three of ITS Client Side Events:

OnMouseOver OnMousemove OnContextMenu

. You might be wondering why we need to handle the third event This is event is raised when user right clicks on the link Since we want to hide the link;. We also would not like the visitors to use "Copy Shortcut" option from the Right Click Menu. Hence, We Also Need To Handle The onContextMenu Event.

Note That Sests Id Write JavaScript code to handle. There is TWO Steps Involved in this:

Attach Client Side Events and Their Event Handler Function in Your Server Side Code. Write Client Side Function To Handle The Events

Attaching Events and Event Handler

In Order to Attach A Client Side Event and ITS Handler ASP.NET Provides An Attributes Collection. You Can Use this Collection As Follows:

Hyperlink1.attributes.add ("onmouseover", "hidelink ();"); hyperlink1.attributes.add ("onmousemove", "hidelink ();"); hyperlink1.attributes.add ("onContextMenu", "Return False; "); Here, we are specifying that OnMouseOver client side event will be handled by a function called HideLink () In the OnContextMenu event we simply want to return false to indicate as if that event never fired..

Client Side Function

Here Is The JavaScript Function That Does The Job for US.

Function hidelink () {WINDOW.STATUS = "you do not see the link here!";

Here, We Simply Set The Status Bar Text of The Browser WINDOW To Some Custom Text. That's IT.

Download

You can Download The Complete Sample Code of this Article. Just Click on The Download Link at The Top of this article.

Summary

In this Small Article We Saw HOW One Can Hide Hyperlinks in The Client Browser Using ASP.NET Controls and JavaScript.


New Post(0)