Rajesh
Rajesh

Reputation: 3034

Can i clone an existing iframe and place it in another div?

If I am trying to do $($('#iframeid').clone()).appendTo('#SomeDiv') then once again an http request is sent and the newly appended iframe is now containing a fresh page rather the page with existing data. Any solution? I want to copy the iframe into a specific div structure so that jquery splitter plugin can understand that .

Upvotes: 0

Views: 2742

Answers (2)

apnerve
apnerve

Reputation: 4829

AFAIK, the content inside the iframe doesn't get included when the browsers builds the DOM. So, clone just clones the iframe with its attributes but without the content inside. It is like copy-pasting the <iframe src="SOMEURL">. So, it sends yet another HTTP request for the requested resource.

Upvotes: 3

Vixed
Vixed

Reputation: 3499

Just try:

$('#iframeid').clone().appendTo('#SomeDiv')

You can also use

$('#iframeid').clone().insertAfter('#SomeDiv')

or

$('#iframeid').clone().insertBefore('#SomeDiv')

Upvotes: 3

Related Questions