Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inject some HTML code into Iframe

Status
Not open for further replies.

Srivats

Technical User
Feb 21, 2006
5
IN
Hi guys,

I've a small issue at hand.

I would like to inject some HTML code into a Dynamically created Iframe.

I should NOT use <iframe>.contentWindow.document.write("<p> blah blah...").

Is there any other way thru JavaScrip to do this.

The Reason I cannot use document.write is due to some DomainSecurity Issues.


Please suggest...


Cheers,
Srivats
 
If you're getting domain security issues using one method, you'll get them using ANY method.

Think about what you're really asking: "How can I bypass built-in security checks". Do you really think that if there was a way to do that, that every script kiddie out there wouldn't have figured it out by now?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Okie.... forget about the DomainSecurity.

Is there any other way to inject HTML code into a Iframe without using contentWindow.document.write ?

We have a seperate client framework (Not Browser like IE or Netscape) with full support for JavaScript.
This *Smart Client* could be tweaked to not to raise DomainSecurity issues for certain type of access.

But my n/w admin says, write method cannot be allowed. Hence this question.

I just want to know other ways apart from write() method by which we can inject HTML code into the dynamically created iFrame.

Thanks,
Srivats
 
If security errors are no issue, then I would have thought any DOM methods would work....

Code:
.contentWindow.document.getElementById('someEl').innerHTML = '<b>some stuff</b>';

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hello Dan,

I tried to do the same for a newly created Iframe like
Code:
<iFrame Obj>.contentWindow.document.body.innerHTML = "<p> SOme text.."

But, i get a scripting error saying body is null or not an object.

I found that when an Iframe is created whose src="about:blank", on which I try to set InnerHtml on body, i get Scripting error stating body is null or not an object.

Am I doing something wrong ?

-Srivats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top