Is there a way to copy images from an iframe to a textarea using JavaScript even when the pages and iframe are not on the same domain or server?
If you have any suggestions or solutions, please share!
The iframe containing the images is utilizing ajax to fetch them.
Potential Use Case:
For instance, I am interested in implementing this technique to transfer images from an iframe to the tinymce text-editor within WordPress. For example, displaying an iframe with an image gallery below the text editor, where users can click on an image in the iframe for it to appear in the text-editor (assuming the image has already been uploaded).
Some Proposed Ideas:
It appears that drag-and-drop functionality works on Internet Explorer and Firefox for transferring images.
Additionally, right-clicking to copy and paste images seems to be effective on Internet Explorer and Chrome.
It would also be beneficial if I could retrieve the source of the image as a variable in order to implement attributes such as "class" and "alt".
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Copy images from iframe</title>
</head>
<body>
<textarea style="width:100%;height:400px" >I want to be able to get theme here like this
<img src="http://www.page.com/image.jpg" alt="">
</textarea>
<iframe width="100%" height="400px" src="http://www.page-with-images.com/"></iframe>
</body>
</html>