Submitted by Tracy.Eastwood on Thu, 12/07/2006 - 00:00
Forums

Is it possible in IceBreak to detect a change to the link in the address bar.

I have an example.
When I have a link which contains a values passed from a link, I want to ensure that the link was pressed in order to arrive at the page and not typed in at the top.

Hope this makes sense.

Niels Liisberg

Thu, 12/07/2006 - 00:00

Hi Tracy;

The easy way is to let the link "POST" the page since the the URL always will be as GET. The code looks like :

 
if (getservervar('REQUEST_METHOD')) = 'POST');
  Exsr DoMyStuff;
else;
 ThisIsNoGo;
endif; 

From the link you will need a lite javascript: 

<script>
  function submitForm(Func) {
            document.getElementById("Func").setAttribute("value",Func);
            document.getElementById("form1").submit();
   }
</script> 
 

and the link will be changed to an onclick event.

Hi Tracy,

The REAL solution is not to use JavaScript or POST/GET, but to use the standard for this:

Check wether the HTTP header has a "Referer". If not then the link was manually entered... otherwise the header will contain a link to the page the user is comming from.

This is the standard way for ALL browsers. One problem though.... it IS possible for a "hacker" to create a POST or GET directly to your page if he/she simulates a browser and manually sets the Referer HTTP header. So in combination with checking the Referer HTTP constant, you should also check that a session is already established with the client by using the SesSetVar() and SesGetVar().

Hope this helps you. If not, don't hesitate to ask additional questions.

Best regards,

John Foldager
www.izone.dk

Hi Niels, Tracy!

Niels:
"John - you are brilliant - why didn't I think about that..."
 
I have tried to tell you the last couple of years that I'm brilliant... ohh... ehh... it was the 'Referer' you hadn't thought about....  Still... you should listen a little bit more to what I have to say 

Tracy:
The source Niels shows is what I should have put in my original post, but didn't have the documentation, so...

Best regards,

John Foldager
www.izone.dk