0

My question may seem a already asked and answered to you, but when I searched for this question on SO I came across only the questions about getting attribute of the <iframe> element.
But my question is that "How to get an element's attribute value in the iframe?".
For example if my iframe has an id iframe1 and it's src is https://anonfiles.com/z7E9W640ud/anime-girls-night-sky-scenery-clouds-stars-4K-64_jpg so how can I get the href value of an anchor link with an id download-url in that page?
The main thing, I want to put that value into an another element(most probably a video or an anchor link) with an id linkHere.

I prefer using Vanilla JS or Jquery for this.

Also If I made any mistakes, feel free to correct me.
THANKS IN ADVANCE :)

Light
  • 1
  • 2
  • Does this answer your question? [how to access the element inside iframe, from parent document?](https://stackoverflow.com/questions/19751631/how-to-access-the-element-inside-iframe-from-parent-document) – cloned Jul 07 '21 at 06:38
  • @cloned I don't think so, I want to use the value I get from that page into an another element. – Light Jul 07 '21 at 06:43
  • This is then a different question. What have you tried to get the value into a different element? Where is your effort? – cloned Jul 07 '21 at 06:48

1 Answers1

0

html

function myFunction() 
{
  var x = document.getElementsByTagName("iframe")[0].getAttribute("src"); 
  document.getElementById("demo").innerHTML = x;
}
  • Welcome to StackOverflow. First of all, this is JS and not HTML, and also when providing code examples, also provide some explanation. – crodev Jul 07 '21 at 13:49