Reputation: 2218
I have a website called A i want to display another website called myFrame through A using iframe i want to count all the clicks in myFrame and want to display in my website A.myFrame site is in different domain.I did the following code but its not working
<html>
<body>
Count: <span id="clicks">0</span>
<iframe id="myframe" src="http://www.myFrame.com" class="restricted" height="400px;" width="400px;" scrolling="no" frameborder="0">
</iframe>
</body>
</html>
<script language="javascript">
$(function() {
var clicks = 0;
$('#myframe').contents().find('a').bind('click', function(e) {
e.preventDefault();
clicks++;
$('#clicks').html(clicks);
});
});
</script>
Upvotes: 0
Views: 108
Reputation: 518
nah man i think that if is it on other domain it is not possible otherwise if you can get it on the same domain then it is possible by acquiring all the html by load function and then filter all body and check whether any click was attempted on it and update clicks accordingly!
Upvotes: 0
Reputation: 708
Cross domain scripting is prohibited in major browsers. But you can disable it (which is very, very dangerous for your security) in Chrome by adding --disable-web-security
as the program parameter. I don't how to do it in other browser, though.
Upvotes: 0
Reputation: 67029
There are a number of clickjacking exploitation methods that you could explore, but what you are asking for is not possible because it is a violation of the same origin policy.
Upvotes: 1