Getting the current src of an Iframe - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame

Description

Getting the current src of an Iframe

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
            function GetIFrameUrl()
            {// www  . ja v  a  2s.  c o  m
                console.log('url = ' + document.frames['frame1'].location.href);
            }
        
      </script> 
   </head> 
   <body> 
      <a href="#" onclick="GetIFrameUrl();">Find the iFrame URL</a> 
      <iframe name="frame1" src="http://www.java2s.com" width="100%" height="400"></iframe>  
   </body>
</html>

Related Tutorials