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

Discussion in 'ASP .Net' started by Aykut Canturk, Jun 4, 2008.

  1. 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 ?
     
    Aykut Canturk, Jun 4, 2008
    #1
    1. Advertising

  2. Aykut Canturk

    Joy Guest

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

    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 ?
    >
    >
    >
     
    Joy, Jun 4, 2008
    #2
    1. Advertising

  3. Aykut Canturk

    Munna Guest

    Re: Howto Listen html link clicks and change them in STATIC HTMLpages

    On Jun 4, 4:18 pm, Joy <> 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
     
    Munna, Jun 4, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Graham Thomson
    Replies:
    3
    Views:
    502
    Eki Y. Baskoro
    Dec 18, 2003
  2. Donny
    Replies:
    13
    Views:
    702
    Donny
    Aug 5, 2004
  3. Hardeep Rakhra
    Replies:
    4
    Views:
    2,487
    Hardeep Rakhra
    Feb 9, 2004
  4. Anonieko

    HttpHandlers - Learn Them. Use Them.

    Anonieko, Jun 15, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    566
    tdavisjr
    Jun 16, 2006
  5. PontiMax

    Clicks and double-clicks

    PontiMax, Jul 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    208
    Eliyahu Goldin
    Jul 14, 2004
Loading...

Share This Page