Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Howto Listen html link clicks and change them in STATIC HTML pages.....

Reply
Thread Tools

Howto Listen html link clicks and change them in STATIC HTML pages.....

 
 
Aykut Canturk
Guest
Posts: n/a
 
      06-04-2008
there's an aspnet site. some pages are html and cannot be changed. (no
javascript nor links can be changed).
these pages have links. for example a.html calls b. html like:

<a href="b.html"> page two link </a>

I need a listenet that can understand and say :

"hey somebody requested b.html." and will run some code, some db operations,
and according to result this istener will send b.html or instead of this it
will send another page...

any idea ?


 
Reply With Quote
 
 
 
 
Joy
Guest
Posts: n/a
 
      06-04-2008
Hi Aykut,
In the a.html you will need to capture the "OnClick" event of the anchor
tag....
Something like this <a id = "firstLink" href="b.html"
OnClike="ProcessClick()"> page two link </a>

Then you will need to write the Javascript function:

<script language="javascript">
function ProcessClick()
{
var ancTag = document.getElementById("firstLink");
//check for NULL condition
if(ancTag != null)
{
//Make your DB calls here
//Change the href as following
ancTag.href = "../SomeResult.html";
}
}
</script>

Hope this helps.

Let me know.

regards,
Joy

"Aykut Canturk" wrote:

> there's an aspnet site. some pages are html and cannot be changed. (no
> javascript nor links can be changed).
> these pages have links. for example a.html calls b. html like:
>
> <a href="b.html"> page two link </a>
>
> I need a listenet that can understand and say :
>
> "hey somebody requested b.html." and will run some code, some db operations,
> and according to result this istener will send b.html or instead of this it
> will send another page...
>
> any idea ?
>
>
>

 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      06-04-2008
On Jun 4, 4:18 pm, Joy <(E-Mail Removed)> wrote:
> Hi Aykut,
> In the a.html you will need to capture the "OnClick" event of the anchor
> tag....
> Something like this <a id = "firstLink" href="b.html"
> OnClike="ProcessClick()"> page two link </a>
>
> Then you will need to write the Javascript function:
>
> <script language="javascript">
> function ProcessClick()
> {
> var ancTag = document.getElementById("firstLink");
> //check for NULL condition
> if(ancTag != null)
> {
> //Make your DB calls here
> //Change the href as following
> ancTag.href = "../SomeResult.html";
> }}
>
> </script>
>
> Hope this helps.
>
> Let me know.
>
> regards,
> Joy
>
> "Aykut Canturk" wrote:
> > there's an aspnet site. some pages are html and cannot be changed. (no
> > javascript nor links can be changed).
> > these pages have links. for example a.html calls b. html like:

>
> > <a href="b.html"> page two link </a>

>
> > I need a listenet that can understand and say :

>
> > "hey somebody requested b.html." and will run some code, some db operations,
> > and according to result this istener will send b.html or instead of this it
> > will send another page...

>
> > any idea ?


HI...

What joy suggested works fine... need modification to the html
Content

but there is another way to do that...

i have used only javascript to do such kind of things

here it goes....


add a function on page's onload ...

<body onload="load_content()"> like this..

and in my mark up i have,.....

<a id="mylink" href="Default.aspx">pagol naki</a>

now in load_content() method i have...

function load_content ()
{
var link = document.getElementById('mylink');
link.onclick = function()
{
window.alert('working');
//do your work...
//naviage it to some where else...
}
}

its works pretty fine and don't need to modify any thing on the
current html...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bad ServerSocket ! Listen! Listen! Listen! Donny Java 13 08-05-2004 06:51 PM
Clicks and double-clicks PontiMax ASP .Net Datagrid Control 2 07-14-2004 11:00 AM
Change Link Font Colours and Overriding Them For Special Cases Hardeep Rakhra HTML 4 02-09-2004 04:49 PM
Remember link from user......login.........take them to that link? Graham Thomson Java 3 12-18-2003 08:42 AM
How to detect when user clicks on a broken link to an external web page. ASP .Net 1 10-30-2003 07:58 PM



Advertisments