M
Miroslav Stampar [MCSD.NET / Security+]
I have a problem that is best described by following code:
<a href="http://www.google.com" onclick="new Image().src=\'http://
www.example.com/process.cgi?p=1\'">Google</a>
I want to call cgi script before a link is clicked. Upper example
works as a standalone (AS IS), but...
But, when I attach onclick event programmaticaly, clicked link loads
to fast so image/CGI script doesn't have time to preload. Do you have
any other solution for this problem?
This is the sample page:
<html>
<head>
<title>getElementById example</title>
</head>
<body>
<div id="here">
<td>
<a href ="http://www.google.com">Google</a>
<a href ="http://www.yahoo.com">Yahoo</a>
</td>
</div>
<script>
function fja()
{
var a = new Image();
a.src='http://www.example.com/process.cgi?p=1';
//alert("bla"); ---- when alert is put CGI manages to be called
}
var elementDiv = document.getElementById('here');
var elementsA = elementDiv.getElementsByTagName('a');
for(var i=0;i<elementsA.length;i++)
{
elementsA.onclick=fja;
//alert(elementsA.href);
}
</script>
</body>
</html>
<a href="http://www.google.com" onclick="new Image().src=\'http://
www.example.com/process.cgi?p=1\'">Google</a>
I want to call cgi script before a link is clicked. Upper example
works as a standalone (AS IS), but...
But, when I attach onclick event programmaticaly, clicked link loads
to fast so image/CGI script doesn't have time to preload. Do you have
any other solution for this problem?
This is the sample page:
<html>
<head>
<title>getElementById example</title>
</head>
<body>
<div id="here">
<td>
<a href ="http://www.google.com">Google</a>
<a href ="http://www.yahoo.com">Yahoo</a>
</td>
</div>
<script>
function fja()
{
var a = new Image();
a.src='http://www.example.com/process.cgi?p=1';
//alert("bla"); ---- when alert is put CGI manages to be called
}
var elementDiv = document.getElementById('here');
var elementsA = elementDiv.getElementsByTagName('a');
for(var i=0;i<elementsA.length;i++)
{
elementsA.onclick=fja;
//alert(elementsA.href);
}
</script>
</body>
</html>