eladr
asked on
Detecting click on link inside iframe
i have a simple html page with an iframe.
Inside the iframe i have a page from external site which i cant change.
Can i detect an onclick event when someone clicked the link inside the iframe?
Inside the iframe i have a page from external site which i cant change.
Can i detect an onclick event when someone clicked the link inside the iframe?
ASKER
i was wrong.
the iframe is in my site but it contain a link from other site by js
<html>
<head>
<script>
</script>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<script type="text/javascript"
src="http://server.com/show_links.js">
</script>
</body>
</html>
the iframe is in my site but it contain a link from other site by js
<html>
<head>
<script>
</script>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<script type="text/javascript"
src="http://server.com/show_links.js">
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
good.
im getting error when trying to pass parameters:
document.links[i].onclick= myclick(1) ;
10x
im getting error when trying to pass parameters:
document.links[i].onclick=
10x
ASKER
Also,the link already contains onclick
onclick='ha(2)'
so, i want to join the original onclick with the new onclick
like this
onclick = 'ha(2);myclick()";
i didnt succeded...
var OnClickStr = links[0].onclick;
links[0].onclick = MyLink; + ";" + OnClickStr;
onclick='ha(2)'
so, i want to join the original onclick with the new onclick
like this
onclick = 'ha(2);myclick()";
i didnt succeded...
var OnClickStr = links[0].onclick;
links[0].onclick = MyLink; + ";" + OnClickStr;
Joining the handlers is done like this:
document.links[15].oldclic k=document .links[i]. onclick;
document.links[15].onclick =function( ){this.old click();my click(1)};
document.links[15].oldclic
document.links[15].onclick
You cannot pass parameters when you change the event handler the way I showed.
You need to do it the way Zvonko did. However that will add a new funtion to every link on the page
Michel
You need to do it the way Zvonko did. However that will add a new funtion to every link on the page
Michel
As long as the page is from an external site, there's nothing you can do to detect click on links or anything else.
Batalf