|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
HTML inside InnerFrame
hi,
I have an inner frame inside an html document.On submitting the html,I need to take the html code inside the inner frame including the html and body tags.I am only able to get the code inside the body tag. Can anybody help. regards mathew |
|
#2
|
|||
|
|||
|
RE: HTML inside InnerFrame
I'm not sure I really get this question...could you rephrase it?
|
|
#3
|
|||
|
|||
|
RE: HTML inside InnerFrame
Well I am trying to create an online editor.
So my page contents that i want to edit goes to an iFrame inside an html.This iframe contains another complete html file with html and body tags.After editing I want to save this content including the html and body tags.Clear? |
|
#4
|
|||
|
|||
|
RE: HTML inside InnerFrame
No, not really. Could you post some relevant code?
|
|
#5
|
|||
|
|||
|
RE: HTML inside InnerFrame
Ok This is my html page
<html> <body>.... .... <iFrame id="myiframe" style="...."> </iFrame> Now i add the content of the html page to be edited to this iFrame while the page is being loaded. myiframe.document.body.write("<html><body>Whatever it is..."); And I make changes to the content in iframe using my online editor which is in the same html page itself.It works fine so far.After editing I want to save the contents of iframe including <html><body> tags. I use var txt=myiframe.document.body.innerHTML; This returns only the code within the <body> and </body> part not the whole code.I want all code including the <html> and </html> art.Hoe you all understand this time. |
|
#6
|
|||
|
|||
|
RE: HTML inside InnerFrame
try document.myiframe.document.body.parentElement.oute rHTML
that should get you everything and including <html> Only thing you won't be able to grab is the doctype. |
|
#7
|
|||
|
|||
|
Another problem
A big thanks crisp.That worked.But now I have another problem.When I add the <base href tag I am not able to get the <html><head tags.I only get content from the base href tag.Is there any way to overcome this.
Any way thanks crisp.I posted this question on a number of forums and nobody had the answer.Hope you have answer for the above problem also. regards mathewvp |
|
#8
|
|||
|
|||
|
RE: HTML inside InnerFrame
This works both in IE and in Mozilla; only thing is you'll need to add the <html> tag.
IE also supports outerHTML which includes the <html> tag as well, but Mozilla doesn't support this: Code:
function getsource() {
var html = window.frames['myiframe'].document.getElementsByTagName('HTML');
alert(html[0].outerHTML);
}
|
|
#9
|
|||
|
|||
|
Yet another problem
Thanks crisp.Your last code solved my problem.
Could you please show one best code for writing an entire html page into an iFrame.Before I was writing into a hidden textarea and then writing the contents of the textarea into the iFrame.But now i have an html page which itself contains another textarea.So that creates errors.My html content is stored in a php variable. var txt="<? echo $content; ?>"; gives an unterminated string error Also can you suggest some site where I can refer for javascript functions? regards mathewvp |
|
#10
|
|||
|
|||
|
RE: HTML inside InnerFrame
just escape any quotes using addslashes(); you may also want to escape the forward slash in case there is a </script> in your string.
For javascript I normally use the Devedge reference: http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/ but I built up my knowledge picking up bits and pieces from many sites, forums and by trying out a lot myself. For DOM methods and properties I often find the DOM inspector built in Mozilla very usefull |
|
#11
|
|||
|
|||
|
RE: HTML inside InnerFrame
or.. you can put your script as a source for that <iframe>, just add one ?iframe=1 param, like so
Code:
<iframe src="myscript.php?iframe=1" /> and in yourscript.php i think it is the simplest method.. no need to escape anything... |
|
#12
|
|||
|
|||
|
RE: HTML inside InnerFrame
Thanks for all you people for all the replies.
"addslashes()" still creates problem for me.May be I should try out the code given by zombie.And thanks for the link crisp. |
|
#13
|
|||
|
|||
|
RE: HTML inside InnerFrame
Thanks Zombie your code is one best solution for writing into an iframe.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > HTML inside InnerFrame |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|