# Dynamically generated iframe with zoom inside generates the zmmtg-root div outside the iframe

**URL:** <https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376>\
**Category:** Web\
**Created:** [March 10, 2021, 8:43pm UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376 "2021-03-10T20:43:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MZL](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@MZL](https://devforum.zoom.us/u/MZL)\
**Post date:** [March 10, 2021, 8:43pm UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376/1 "2021-03-10T20:43:39Z")

</div>

**Description**  
Due to the missing CSS functionality I tried to dynamically create an iframe with a web embedded zoom script inside the iframe.  
I created the iframe with:

```
var iframehead = `
			<meta charset="utf-8">
			<meta name="viewport" content="width=device-width, initial-scale=1.0">
			<title>Zoom Iframe</title>
			<link rel="stylesheet" href="https://source.zoom.us/1.9.0/css/bootstrap.css" type="text/css" />
			<link rel="stylesheet" href="https://source.zoom.us/1.9.0/css/react-select.css" type="text/css" />
			<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
			<script src="https://source.zoom.us/1.9.0/lib/vendor/react.min.js"></script>
			<script src="https://source.zoom.us/1.9.0/lib/vendor/react-dom.min.js"></script>
			<script src="https://source.zoom.us/1.9.0/lib/vendor/redux.min.js"></script>
			<script src="https://source.zoom.us/1.9.0/lib/vendor/redux-thunk.min.js"></script>
			<script src="https://source.zoom.us/1.9.0/lib/vendor/lodash.min.js"></script>
			<script src="https://source.zoom.us/zoom-meeting-1.9.0.min.js"></script>
			`;

		var iframebody=	`			
			<script>
			console.log('iframetext loaded');
			ZoomMtg.setZoomJSLib('https://source.zoom.us/1.9.0/lib', '/av'); 
			console.log('checkSystemRequirements');
			console.log(JSON.stringify(ZoomMtg.checkSystemRequirements()));
			ZoomMtg.preLoadWasm();
			ZoomMtg.prepareJssdk();
			const zoomMeeting = document.getElementById('zmmtg-root');
			ZoomMtg.init({
				debug: true,
				screenShare: true,
				isSupportChat: true,
				leaveUrl: 'https://example.de/out2.php',
				isSupportAV: true,
				success: function() {
					console.log('zoom init successfully');
					ZoomMtg.join({
							signature: '` + data.signature + `',
							meetingNumber: ` + data.config.mid + `,
							userName: '` + app.talk.user.name + `',
							apiKey: '` + data.config.apikey + `',
							passWord: '` + data.config.password + `',
							success: (success) => {
								console.log('zoom join successfully: ' + success)
								},
							error: (error) => {
								console.log('error joining zoom: ' + error)
								}
							})		
					},
				error: function() {
					console.log('error initiating zoom: ' + error)
					}
				});		
				</script>
			`;
		  $('<iframe scrolling="no" allow="microphone; camera" id="zoomIframe" width="800px" height="600"" />').appendTo('#wrapper').contents().find('head').append(iframehead);
		  $('#zoomIframe').contents().find('body').append(iframebody);

```

**Error**  
First error: Ok, thats my fault. Dynamically generated/inserted JS inside an iframe (body part) doesn´t work this way. I have to use eval().

Second and main error: In the header of the iframe, zoom-meeting-1.9.0.min.js is loaded and generates the

```
<div id="zmmtg-root"></div>
<div id="aria-notify-area" aria-atomic="true" aria-live="assertive"></div>

```

outside of the iframe in my main page and not inside the iframe.  
Is there a way to generate the zmmtg-root and aria-notify-area in the body part of the iframe?

**Which Client Web SDK version?**  
1.9.0

**Device (please complete the following information):**

- OS: Win 10
- Browser: Chrome
- Browser Version 89.0.4389.82

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [March 11, 2021, 9:51pm UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376/2 "2021-03-11T21:51:17Z")

</div>

Hey @MZL,

Thank you for reaching out to the Zoom Developer Forum. You’ve identified some interesting behavior here but it seems to be expected based on how the [Web SDK](https://marketplace.zoom.us/docs/sdk/native-sdks/web#zoom-web-sdk) works.

Currently, the Web SDK is not designed to be placed inside of an iFrame and instead is rendered directly on the page where it’s used. The behavior where the `div` is placed outside of the iframe that you’ve created seems to be due to this.

I would try adding the Zoom meeting window similar to the example that we have in our [Sample Web App](https://github.com/zoom/sample-app-web) or [Sample Angular App](https://github.com/zoom/websdk-sample-angular).

I hope that helps! Let me know if you have any questions.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![aftabh2018](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/aftabh2018/32/17366_2.png) [@aftabh2018](https://devforum.zoom.us/u/aftabh2018)\
**Post date:** [March 12, 2021, 6:17am UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376/3 "2021-03-12T06:17:19Z")

</div>

When opening zoom in browser with client Web SDK or without We are not getting advance feature like whiteboard and screen Portion sharing… Please help urgently

---

<div class="post-metadata">

**Author:** ![MZL](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@MZL](https://devforum.zoom.us/u/MZL)\
**Post date:** [March 12, 2021, 8:19am UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376/4 "2021-03-12T08:19:27Z")

</div>

I got it to work with eval(), see

> <https://stackoverflow.com/questions/12773361/is-there-anyway-of-getting-javascript-code-injected-in-an-iframe-to-execute-with>

Be aware that you also have to load and wait for jquery and/or the zoom-js-files in the injected script before fireing the ZoomMtg.  
You can do this with defer function: [javascript - How to make script execution wait until jquery is loaded - Stack Overflow](https://stackoverflow.com/questions/7486309/how-to-make-script-execution-wait-until-jquery-is-loaded)

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [March 12, 2021, 9:11pm UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376/5 "2021-03-12T21:11:07Z")

</div>

@MZL, I’m glad to hear that you found a solution that works for you! Please note, you may encounter further issues when using the [Web SDK](https://marketplace.zoom.us/docs/sdk/native-sdks/web#zoom-web-sdk) from an iFrame.

@aftabh2018 I see that you have submitted a forum topic for this. I’ll follow-up with you there.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [April 12, 2021, 7:11am UTC](https://devforum.zoom.us/t/dynamically-generated-iframe-with-zoom-inside-generates-the-zmmtg-root-div-outside-the-iframe/45376/6 "2021-04-12T07:11:34Z")

</div>

Closed on April 12, 2021, 7:11am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
