Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 7th, 2003, 07:40 AM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #2  
Old July 7th, 2003, 11:50 AM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: HTML inside InnerFrame

I'm not sure I really get this question...could you rephrase it?

Reply With Quote
  #3  
Old July 7th, 2003, 12:10 PM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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?

Reply With Quote
  #4  
Old July 7th, 2003, 12:26 PM
mugane mugane is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Charlottesville, VA USA
Posts: 425 mugane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to mugane Send a message via Yahoo to mugane
RE: HTML inside InnerFrame

No, not really. Could you post some relevant code?

Reply With Quote
  #5  
Old July 7th, 2003, 02:26 PM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.


Reply With Quote
  #6  
Old July 7th, 2003, 04:04 PM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #7  
Old July 8th, 2003, 07:17 AM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #8  
Old July 8th, 2003, 08:44 AM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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);

}

Reply With Quote
  #9  
Old July 8th, 2003, 12:06 PM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #10  
Old July 8th, 2003, 06:58 PM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #11  
Old July 8th, 2003, 09:58 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
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

php Code:
Original - php Code
  1.  
  2. if ($_GET['iframe']) {
  3.     die($content);
  4. }


i think it is the simplest method.. no need to escape anything...

Reply With Quote
  #12  
Old July 9th, 2003, 07:09 AM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #13  
Old July 9th, 2003, 02:31 PM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: HTML inside InnerFrame

Thanks Zombie your code is one best solution for writing into an iframe.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > HTML inside InnerFrame


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |