June 10, 200818 yr Hey ppl, Searched the internet for a while now but came up with nuthing. I'm looking for a piece of code (probably Javascript) That can tell when a user has clicked a button / link inside an iFrame. I have no control over the content of the iFrame so the code needs to be entirely outside the iFrame. I know iFrame's are far from ideal, but i really don't have a choise in this case Appreciate any help you can give me. Greetz R-J
June 10, 200818 yr Is the URL being displayed in the iframe in a different domain than the URL of the surrounding webpage? If so you are going to run up against JavaScript security. JavaScript is designed to prevent code from a page in one domain knowing what the user is doing on a page from another domain. This is to prevent malicious code things like finding out what password you are entering for another site. This security feature is core part of JavaScript and so you won't find any workarounds. If you are the creater of the page being displayed in the iframe you could maybe adapt that page so that when the user pressed a button in that page some JavaScript ran which sent a message to domain of the main page.
June 11, 200818 yr Author Is the URL being displayed in the iframe in a different domain than the URL of the surrounding webpage? If so you are going to run up against JavaScript security. JavaScript is designed to prevent code from a page in one domain knowing what the user is doing on a page from another domain. This is to prevent malicious code things like finding out what password you are entering for another site. This security feature is core part of JavaScript and so you won't find any workarounds. If you are the creater of the page being displayed in the iframe you could maybe adapt that page so that when the user pressed a button in that page some JavaScript ran which sent a message to domain of the main page. Hmm k thanks, The website will be on another domain so i gues it's not gonna happen
Create an account or sign in to comment