I am trying to retrieve the url from an iframe and successfully managing to do so, but I can only pick up the main domain, not the current url that the iframe is on. For instance if I am on http://dave.com/a_page it wil only return http://dave.com. I am trying to extract the url from a subdomain of the domain I have the iframe on.

Here is my code:

        <script>
        function setSrc(obj, url) {
        obj.src = url;
        }
        function getSrc(obj) {
        alert(obj.src);
        return obj.src;
        }

        document.getElementById("frameid").value = myframe; 
        </script>
        <p><a href="#" onclick="javascript:getSrc(document.getElementById('myframe'))">Get src</a></p>

For others who don't know. Just directly retrieve the url from its src attribute?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.