|
|
Subject:
Web programing, javascript: Grabbing a URL from an iFrame on my Web site
Category: Computers > Internet Asked by: jec1000-ga List Price: $25.00 |
Posted:
18 Jul 2006 13:03 PDT
Expires: 17 Aug 2006 13:03 PDT Question ID: 747455 |
I have a web site that uses an iframe in it to allow the user to view other Web pages while he or she visits and uses some simple apps on my site. I would like to use javascript within my site to grab the website URL that the user is currently visiting (inside the iframe), so as to be able to help the user remember which URL he last visited. However, when I try to get the source using javascript it will always tell me the original source of the iframe and not the page after the user has changed it by navigating. Is there any way to do this using javascript or PHP? Thank you. |
|
There is no answer at this time. |
|
Subject:
Re: Web programing, javascript: Grabbing a URL from an iFrame on my Web site
From: cnkunee-ga on 01 Aug 2006 04:33 PDT |
hi, it is an example below which works in ie6 <html> <head> <title>Test</title> </head> <script language=javascript> var preObj function getFrameSrc(obj) { if(preObj)document.getElementById('Show').innerHTML="Current Location:"+preObj.href; } function SaveObj() { preObj=event.srcElement; if(preObj && (preObj.tagName=='a'|| preObj.tagName=='A'))document.getElementById('Show').innerHTML='Loading...'; } document.onclick=SaveObj </script> <body> <ul> <li> <a href="://www.google.com" target="a">Google.Com</a></li> <li> <a href="http://www.yahoo.com" target="a">Yahoo.Com</a> </li> <li> <a href="http://www.kunee.com" target="a">Kunee.Com</a> </li> <li> <a href="http://www.china.com" target="a">China.Com</a> </li> </ul> <span ID=Show style=padding:5px;font-weight:bold></span> <br/><br/><br/> <iframe id=a name=a style="height:100%;width:100%;" onload=getFrameSrc(this)></iframe> </body> </html> |
Subject:
Re: Web programing, javascript: Grabbing a URL from an iFrame on my Web site
From: cnkunee-ga on 01 Aug 2006 04:53 PDT |
there is a bug . try this <html> <head> <title>Test</title> </head> <script language=javascript> var preObj function getFrameSrc(obj) { if(preObj)document.getElementById('Show').innerHTML="Current Location:"+preObj.href; } function SaveObj() { var obj=event.srcElement; if(obj && (obj.tagName=='a'|| obj.tagName=='A'))preObj=obj; if(preObj && (preObj.tagName=='a'|| preObj.tagName=='A'))document.getElementById ('Show').innerHTML='Loading...'; } document.onclick=SaveObj </script> <body> <ul> <li> <a href="://www.google.com" target="a">Google.Com</a></li> <li> <a href="http://www.yahoo.com" target="a">Yahoo.Com</a> </li> <li> <a href="http://www.kunee.com" target="a">Kunee.Com</a> </li> <li> <a href="http://www.china.com" target="a">China.Com</a> </li> </ul> <span ID=Show style=padding:5px;font-weight:bold></span> <br/><br/><br/> <iframe id=a name=a style="height:100%;width:100%;" onload=getFrameSrc(this)></iframe> </body> </html> |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |