BetaArchive Logo
Total Current Archive Size: 4765.54GB in 15409 files
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 9d, 4h, 37m | CPU: 26% | MEM: 5344MB of 12279MB used
{The community for beta collectors}

Forum rules


Before you post, please make sure...

- ...you have first used Google to look for an answer, and you have asked other people you know via other methods (IM, e-mail, etc).
- ...your question has not been asked before. Search the forum first before posting.

If you meet those criteria, go ahead and post your question. Be sure to provide as much information you can about the problem and how to recreate it. Also provide information on hardware and software if applicable.


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 PostPost subject: IFrame innerHTML        Posted: Wed Mar 07, 2012 11:12 pm 
Amateur Beta Collector
Amateur Beta Collector
User avatar
Offline

Joined
Tue Jun 07, 2011 4:45 pm

Posts
80

Location
Planet Earth

Favourite OS
WebEdit
Is it possible to set the innerHTML of an iframe from something like a php variable or javascript variable?
I have searched on this and haven't found anything on setting the innerHTML just reading it.

I have used this type of script to change div's but am looking to change iframes

Code:
<script type="text/javascript">
document.getElementById('text').innerHTML = "<p>Hello</p>";
</script>   


suggestions?


Top  Profile  WWW
 PostPost subject: Re: IFrame innerHTML        Posted: Thu Mar 08, 2012 12:42 am 
Guru Beta Collector
Guru Beta Collector
Offline

Joined
Tue Oct 17, 2006 8:26 pm

Posts
822
an iframe is a whole new window/document. You will need to do document.getElementById('whatever').body.innerHTML, or possibly document.getElementById('whatever').document.body.innerHTML (depending on the browser, an iframe may or may not resolve to a window instead of a document... I remember old Opera doing this)


Top  Profile
 PostPost subject: Re: IFrame innerHTML        Posted: Thu Mar 08, 2012 12:43 am 
Guru Beta Collector
Guru Beta Collector
Offline

Joined
Tue Oct 17, 2006 8:26 pm

Posts
822
Also, if the iframe is pointing to a document in a different domain, you may not be able to edit anything (XSS)


Top  Profile
 PostPost subject: Re: IFrame innerHTML        Posted: Thu Mar 08, 2012 8:47 am 
Site Administrator
Site Administrator
User avatar
Offline

Joined
Fri Aug 18, 2006 11:47 am

Posts
11402

Location
Merseyside, United Kingdom

Favourite OS
Microsoft Windows 7 Ultimate x64
If you don't want to load in a new page but just content you would be better using a div with overflow auto on it.

_________________
Image


Top  Profile  WWW
 PostPost subject: Re: IFrame innerHTML        Posted: Tue Mar 27, 2012 10:04 pm 
Amateur Beta Collector
Amateur Beta Collector
User avatar
Offline

Joined
Tue Jun 07, 2011 4:45 pm

Posts
80

Location
Planet Earth

Favourite OS
WebEdit
I could not find a solution for setting the innerhtml but i was able to read the inner html
My solution for this problem ended up passing the needed variables to the page that i had the iframe loading and was then able to save them also.


Top  Profile  WWW
 PostPost subject: Re: IFrame innerHTML        Posted: Tue May 15, 2012 8:03 pm 
Newbie Beta Collector
Newbie Beta Collector
User avatar
Offline

Joined
Fri May 11, 2012 4:36 am

Posts
21

Location
Brazil

Favourite OS
Windows 7
Try This:

document.getElementById("iframe").src="data:text/html;,"+text;

_________________
Wanted: Microsoft Windows 95 OSR 2.5 PT-BR; Microsoft Windows ME Full OEM/Retail PT-BR


Top  Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 




Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2013

 

Sitemap | XML | RSS