I want to get the value of the TAG which "id" is "token" from the iframe (id: 'myFrame'), but i get a "null" value displayed.
I guess the problem is that the iframe is not loaded before the javascript get executed but i don't know how to solve this problem.
Thanks
<!DOCTYPE html>
<html>
<head>
<title>Smth</title>
</head>
<body>
<iframe src="script.php" name="myFrame" id="myFrame"></iframe>
<script>
var iframe = document.getElementById('myFrame');
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
document.write(innerDoc.getElementById("token").value);
</script>
</body>
</html>