Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include a webpage inside a div

Tags:

html

iframe

I have to include a webpage inside my webpage's div. I want somehting like iframe to be done with DIV. Basically, I will be providing a URL to my div and it has to open it inside itself... Do we have something like this in modern HTML? I cannot use frames as some browsers have issues with frames.

like image 622
Varun Avatar asked Jul 07 '11 09:07

Varun


People also ask

How do you display a page inside a another page in HTML?

The HTML <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document.

Can you write inside a div?

Any sort of content can be put inside the <div> tag!

How do you write inside a div in HTML?

HTML code can be appended to a div using the insertAdjacentHTML() method. However, you need to select an element inside the div to add the code. This method takes two parameters: The position (in the document) where you want to insert the code ('afterbegin', 'beforebegin', 'afterend', 'beforeend')


1 Answers

Nope. You can't embed a complete HTML document inside another div element as this is a block level element and W3C has defined what could be included inside it.

But there is a workaround. Follow these steps:

  1. Get the document using ajax (jQuery rocks, use that)
  2. Extract the content of the <body> element and put it inside your div element
  3. Get all links and script of <head> element and append them to the <head> element of your existing pgae.
like image 131
Saeed Neamati Avatar answered Oct 11 '22 03:10

Saeed Neamati