0

I'd like to parse my iframe using jquery, I need for example to search in the iframe document the string "Ctrl".

Url of my iframe : http://windows.microsoft.com/fr-xf/internet-explorer/ie-keyboard-shortcuts#ie=ie-11

$('#iframeIe').contents()

Error message :

Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://localhost:4000" from accessing a cross-origin frame.(…)

Is there any other method to include websites on a page and parse them? I mean parse their text contents...

tonymx227
  • 5,293
  • 16
  • 48
  • 91

2 Answers2

0

I recommend you this thread

You can try the snippet of this thread :

$(function(){//document ready
    $('some selector', frames['nameOfMyIframe'].document).doStuff()
});

Or take a look at the answers if you have the permission denied errors

Community
  • 1
  • 1
bviale
  • 5,245
  • 3
  • 28
  • 48
-2

You can use AJAX:

$.ajax({
  url: "yourwebsiteurl",
  async: false,
  dataType: 'html',
  cache: false,
  success: function(html){
    $(".div").append(html); // for example append your html to a specific object 
  }
});

Keep in mind that you can only get data from pages that are within the same domain otherwise it will complain about cross-browser origin kind of annoying stuff ;).

Rotan075
  • 2,567
  • 5
  • 32
  • 54