I have two questions. This is core component of a project I'm currently working on. I'm looking for a way to manipulate/edit the source code of an iFrame whose "src
" will always be changing: a dynamic iFrame. Is this possible? I know that it's really not recommended because of the potential security issues.
And my other question is: Is it possible to retrieve the selected text inside a iFrame that's also dynamic?
I've searched for answers on Google, and found no results. Please help me. :-)
-
An iframe is just another webpage inside the one you are looking at. It has the same javascript functions and methods a normal webpage has.
To access it:
document.getElementById('iframeID').contentDocument (DOM)
Look here for cross-browser access: http://www.dyn-web.com/tutorials/iframes/
And here for getting the selected text: http://www.codetoad.com/javascript_get_selected_text.asp
Combining them:
document.getElementById('iframeID').contentDocument.getSelection(); (DOM)
As for manipulating source code, I don't know what you want to do, but Javascript (jQuery) may be the best choice.
Emil Hajric : Thank you very much macaco. I really appreciate your time and advice. I'm going to try out the code right now!
0 comments:
Post a Comment