...

View Full Version : iframe and its location.href



Garadon
06-11-2003, 09:08 PM
I have made this litte code to show my problem, it makes an
iframe with the name and id 'test', then make a var test to point
to this iframe, my problem it the var says that location.href ain't an object. but if I write document.test.location.href it is, I would like a solution that lets me make a var called test and then reference location by
test.location.href

EXAMPLE CODE:
<html>
<head>

</head>
<body>
<iframe id="test" name="test"></iframe>
<script>
var test=document.getElementById('test');
alert(test.width);
alert(document.test.location.href);
alert(test.width);
alert(test.location.href);

</script>

</body>
</html>

realisis
06-11-2003, 09:16 PM
that's because the iframe is a distinct window ... try accessing its location via:

windowname.location.href

notice that 'document' is not used.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum