Scott
Scott

Reputation: 121

Get iframe src param from inside the iframe itself if i dont have its id attribute but i have name attribute

How can I get the iframe src param from inside the iframe itself if I don't have its id attribute but I have name attribute of it?

For example:

<iframe name="ambiguous" src="some src here"></iframe>

Upvotes: 0

Views: 588

Answers (2)

Dusty
Dusty

Reputation: 364

you can try frameElement.src on console if you're inside the iframe

Upvotes: 0

R3tep
R3tep

Reputation: 12854

You can get access like :

document.getElementsByName("ambiguus").item(0).getAttribute("src");

Note :

This solution works if the name is unique on your HTML page


Reference

Upvotes: 1

Related Questions