Outside click detection inside an iframe?

Here is the script. Content uploaded to an iframe from another site. I click on the link inside the iframe.

Is there any way to go beyond the iframe, what is this link?

UPDATE Since I got the question, if my intentions are pure, I will explain more about use. Maybe I started in the wrong direction for this task.

So, we have a desktop client that goes around the network (for purchases actually), and when the client finds what he wants to buy, she clicks on โ€œthisโ€ (something - an image, link, address) and sends โ€œthisโ€ to our service, where it is manually allowed to link to the product and converted into an entry in its registry. Nothing unusual.

Now the challenge is to make this a web application. Thus, the client registers on our website and begins browsing online stores. So my first choice was iframe. But the question is, how to find what she clicked on?

Or, as a rule, how to save a โ€œbookmarkโ€ to an object from another site?

+3
source share
6 answers

If the pages are not located in the same domain, then there is no way to do this. Your scripts are not visible in different domains.

+5
source

If this is from another site, then the only way I know is to record the information needed for the iframe property of window.name.

This , you can read from your main document.

+1
source

div-, div ontop iframe , .

https://gist.github.com/729591

+1

iframe , onclick .

:

<a href="javascript:void(0)" onclick="top.harvestLink(this)" title="Item=foo" alt="">Foo</a>

iframe :

function harvestLink(anAnchor,aShoppingListArray) {
  var itemName = anAnchor.title.split("=")[1];
  aShoppingList.push({item:itemName,dateStamp:new Date()});
}

, . , -, , "title" . . ( , IMO) , "button" IE .

0

. window.name, , . window.name, .

, window.name , 404 . iframeID.contentWindow.name . iframe.

, , , , , . , .

0

, , - . , , , -, .

- javascript, , , , .

, Facebook Share Bookmarklet, Delicious.

- , , . Firefox, - .

0

Source: https://habr.com/ru/post/1699150/


All Articles