Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

iFrame Listener

Featured Replies

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 :pp

 

Appreciate any help you can give me.

 

Greetz R-J

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.

  • 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 :pp

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.