how would find the url of the page loaded in a iframe with javascript?
here is the code for the iframe i am useing
Code: Select all
<iframe name="redirect" src="redirect.php?id=23" width="25%" hight="50%"></iframe>please help.
thanks alot.
Moderator: General Moderators
Code: Select all
<iframe name="redirect" src="redirect.php?id=23" width="25%" hight="50%"></iframe>Code: Select all
<script language="javascript">
var intervalID = setInterval('getlocation()',1000); //check every 1000 msecs
function getlocation()
{
if(parent.redirect.document.readyState == 'complete') //check if document in redirect is loaded
{
var frame_location = parent.redirect.document.location.href; //get the document's location
clearInterval(intervalID); //stop the timer
}
}
</script>Code: Select all
<iframe name="redirect" src="http://localhost/data/redirect.php?ID=23"></frame>
<iframe name="aaa" src="http://localhost/data/page2.htm"></iframe>Code: Select all
<script language="javascript">
var intervalID = setInterval('getlocation()',1000); //check every 1000 msecs
function getlocation()
{
if(parent.redirect.document.readyState == 'complete') //check if document in redirect is loaded
{
var frame_location = parent.redirect.document.location.href; //get the document's location
clearInterval(intervalID); //stop the timer
}
}
</script>Code: Select all
<script language="javascript">
var timeoutID = setTimeout('getlocation()',5000); //check after 5000 msecs
function getlocation()
{
var frame_location = parent.redirect.document.location.href; //get the document's location
}
</script>
i haven't tested it but give it a shot... hope it helps