Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get parentNode of Current Script Tag

Is there any way to get the parent node of current script tag. I wanted to assign id attribute to the script tag but found that it does not support standard attributes.

Actually I want to get the title of a document inside a frame and document.title is returning the title of the webpage.

like image 601
Irfanullah Jan Avatar asked Sep 04 '25 03:09

Irfanullah Jan


1 Answers

I believe this is what you are looking for:

document.currentScript.parentNode

The documentation for Document.currentScript says:

Returns the element whose script is currently being processed.

like image 93
maxpaj Avatar answered Sep 05 '25 18:09

maxpaj