Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get src of IFRAME

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
US
This should alert "
How is it done?

Code:
<script language="javascript">
function capture(){

    alert(document.frames['ifPreview'].????);

}
</script>

<form id="Form1">

<IFRAME id="ifPreview" name="ifPreview" src="[URL unfurl="true"]http://www.tek-tips.com"></IFRAME>[/URL]

<a href="#" onclick="capture();">capture</a>
</form>

Thanks!!
 
Actually, got THAT working with

Code:
alert(document.getElementById('ifPreview').getAttribute('src'));

But when I click a link in document in the IFrame, the src stays the same - I was expecting it to change every time the actual location in the Iframe changes. Is there any way to get that url?
 
Try this:
alert(document.frames['ifPreview'].location.href);

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top