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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aykut Canturk

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

    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"pa ge 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 ?


  • =?Utf-8?B?Sm95?=

    #2
    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="Proces sClick()"page two link </a>

    Then you will need to write the Javascript function:

    <script language="javas cript">
    function ProcessClick()
    {
    var ancTag = document.getEle mentById("first Link");
    //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"pa ge 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 ?
    >
    >
    >

    Comment

    • Munna

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

      On Jun 4, 4:18 pm, Joy <J...@discussio ns.microsoft.co mwrote:
      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="Proces sClick()"page two link </a>
      >
      Then you will need to write the Javascript function:
      >
      <script language="javas cript">
      function ProcessClick()
      {
      var ancTag = document.getEle mentById("first Link");
      //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"pa ge 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_co ntent()"like this..

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

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

      now in load_content() method i have...

      function load_content ()
      {
      var link = document.getEle mentById('mylin k');
      link.onclick = function()
      {
      window.alert('w orking');
      //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



      Comment

      Working...