Iframe from external site

Asked

Viewed 502 times

1

I have a page with iframe of external site, how can I do to be able to click automatically when loading the iframe on a button you have determined texto on the external website?

Not exactly classe, id or name, but by the text that appears on the same button, like searching inside the iframe a certain word and have a click action above the text.

The question is how to do this, there is another way to load the site in the same way as the iframe does so that inside my page I can interact with the external site?

I appreciate help

  • I think this question is duplicated from http://answall.com/a/102744/129

2 answers

2

You can access the iframe by id (best) or use $('iframe')[0]contents(), [0] is an index. If there is more than one iframe, you will need to set another value.

To access an input per value do so:

$('#iframeID').contents().find('input[type="button"][value="Valor desejado"]');

So just use the element.

  • Thank you Ricardo Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement is the message that appears to iframe with external site

  • Got it. When you say external site you mean off the domain is that (for example the site xxx.com.br opens the iframe of yyy.com.br)? If it is, for security reasons you can’t even handle content and content, just from the same domain or sub-domain.

0

I believe you can use a Text Highlighter plugin to find the word, and after that add a click event.

Here is a site with the list of plugins that can assist you in the task. Site with the list of plugins

I ran a test on MARK.JS and I was able to click the words that are found.

but I did not take the test using Iframe, but I believe that with this you already have an idea.

See the result on jsfiddle

 $('mark').on('click', function(){
        alert('teste');
    } );

NOTE: the code is from the mark.js website itself, I just added the above lines of code to add the event the words found.

  • Thank you Abner, the warning is not working for me in the example you sent, not even the original example of the code you indicated. But I had an idea to do some tests with these plugins

  • Seriously ? The worst that came out right here, more basically for you to understand, when searching for a word it creates a tag mark , using this selector you can assign the click event. hope it helps !

  • However, it’s like Ricardo Pontual commented, you can’t manipulate websites that aren’t in your domain, and if you’re using a subdomain and you have access to the files, I recommend using the old ajax + div, that is, loading the html page inside a div.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.