DeanWhitehouse Posted November 11, 2008 Share Posted November 11, 2008 <script> function change_iframe() { i_frame = document.getElementById("i_frame"); host = window.location.hostname; locat = "http://xyz.com/file.php?id="+host; i_frame.src=locat; } </script> <body onload="change_iframe()"> <iframe id="i_frame" src=""></iframe> Guaranteed to work, tried and tested. Modified: To add a get code feature <script> host = window.location.hostname; locat = "http://xyz.com/file.php?id="+host; function change_iframe() { i_frame = document.getElementById("i_frame"); i_frame.src=locat; } function get_code() { div = document.getElementById("code"); code = '<textarea rows="2" cols="50"><iframe src="'+locat+'"></iframe></textarea>'; div.innerHTML = code; } </script> <body onload="change_iframe()"> <iframe id="i_frame" src=""></iframe> <br> <a href="Javascript:get_code();">Get Code</a> <div id="code"> </div> Quote Link to comment https://forums.phpfreaks.com/topic/132100-solved-grab-webpage-url-from-iframe/page/2/#findComment-687431 Share on other sites More sharing options...
allex01 Posted November 11, 2008 Author Share Posted November 11, 2008 The following did the job, <body> <iframe id="i_frame" src=""></iframe> </body> <script> host=window.location.hostname; locat="http://xyz.com/file.php?url="+host; i_frame = document.getElementById("i_frame"); i_frame.src=locat; </script> Thanks blade and to everyone who helped in this matter. Quote Link to comment https://forums.phpfreaks.com/topic/132100-solved-grab-webpage-url-from-iframe/page/2/#findComment-687937 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.