Pirta Matharu
Pirta Matharu

Reputation: 285

How to get src from iframe vuejs

I get html of iframe from DB , now i need iframe url only

How i get iframe src in nuxtJs

<iframe title="LD SKOOL (Full Video) Prem Dhillon ft Sidhu Moose Wala" width="640" height="360" src="https://www.youtube.com/embed/hBlO1i_WTiY?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Upvotes: 2

Views: 5455

Answers (1)

Hiren F
Hiren F

Reputation: 529

Assign a reference,

<iframe ref="iframeRef" />

and you can get the src as per below,

this.$refs.iframeRef.getAttribute('src');

iframeRef is reference name I have provided to iframe.

If you can't update Iframe tag in your DB, than you can assign ref to parent container, and then find iframe from the children nodes of that element.

this.$refs.iframeContainerRef.children will return all children HTML elements of that container, you can find iframe from it.

Upvotes: 2

Related Questions