-3

I need to load an html page inside a div in the following pseudo page:

<html> <head></head> <style> body { background-color: yellow; } </style> <body> <div style="display:none"> <html> <head></head> <style> body { background-color: blue; } </style> <body> <div style="display:none"> ... </div> </body> </html> </div> </body> </html> 

What naturally happens in this code is that the background will turn blue, as it is being changed in the middle of the page. Is there a way to isolate this div? So it would act similarly to an iframe. The content inside the div is stored in a variable, so I think I cannot use a frame, as the html code is not stored in a file to use it as a source.

Thank you!

6
  • 1
    While this HTML will load in most browsers, it is very much invalid HTML. I suggest you work out how to strip the embedded HTML of the <html> to (and including) <body> as well as the closing </body></html> first. Commented Apr 28, 2016 at 8:22
  • better create one body and instead of new html body tag use custom div. Commented Apr 28, 2016 at 8:23
  • I have a script to send e-mails to multiple users, but I wanted to let the user preview the html e-mail before sending. Commented Apr 28, 2016 at 8:25
  • 2
    Take a look at this post stackoverflow.com/questions/6102636/… Commented Apr 28, 2016 at 8:25
  • style="display:none" then how user will see the content of div? Commented Apr 28, 2016 at 8:26

2 Answers 2

2

This is just wrong. An HTML document can only have one html tag and one body tag, otherwise it will be an invalid document, browsers won't allow it.

If you load an iframe, instead, it will have his own #document and it's fine.

Sign up to request clarification or add additional context in comments.

Comments

2

You can not load a Site into a Site without an Iframe due to security risks.

The only thing you can do, is to load the external Site with a serverside script like php, cut of the head with regexp and send the rest to your site into your div.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.