Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 7th, 2005, 03:37 AM
arjan arjan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 arjan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How do I get the URL of an iframe

if I use the getURL() command, i get the source of the current page, right?

Now I want to get the source of an iframe...

can someone help me?

thanks!

Reply With Quote
  #2  
Old January 7th, 2005, 09:37 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 14
Here's an example I just wrote up to get/set the source of an IFRAME... It uses DOM...

Its may me complicated for what it's worth, but all you really need to do is one of the following:
window.frames['my_frame_name'].src
document.getElementById('my_frame_id').src


Depends on your code... notice the difference between name and Id...
My example uses the second example above...

Code:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Changing IFRAME Src</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
<!--
function setSrc(obj, url) {
	obj.src = url;
}

function getSrc(obj) {
	alert(obj.src);
	return obj.src;
}
//-->
</script>
</head>
<body>

<h1>Changing IFRAME src</h1>

<p><a href="#" onclick="javascript:setSrc(document.getElementById('myframe'),'new.htm  ')">Change src</a> <b>|</b> 
<a href="#" onclick="javascript:getSrc(document.getElementById('myframe'))">Get src</a></p>

<iframe id="myframe" src="old.htm"></iframe>

</body>
</html>
I've highlighted the key points of the code.

Reply With Quote
  #3  
Old February 16th, 2006, 12:54 AM
childish_gal81 childish_gal81 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 1 childish_gal81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 25 sec
Reputation Power: 0
hi,

Can you show me how to use the first example? When I use the second one (document.getElementById..), even after my page URL has change , the value is still old URL. I tyr to use frames[iframe_name].location.href;

but i get permission denied.
Please help.

Reply With Quote
  #4  
Old March 15th, 2006, 02:14 PM
Denver Dave Denver Dave is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 1 Denver Dave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 44 sec
Reputation Power: 0
I have exactly the same question. I have been able to get the original (old) src url with:
alert(document.getElementById('I1').src);
but this does not change as visitors click on navigation links within the iframe.

From another angle, the urls are present in the history array and available with back and forward, but can't seem to display the actual iframe url address text - must be a security thing (probably good).

The iframe onload event does fire, but likewise, can't seem to get anything useful here.

I don't like it, but I haven't seen any discussion that we can access the current url for an iframe. Wonder if this is a general issue with frames or just iframe. I'm going to try to do an example with frames instead of iframes and see if the same issue exists. Any one try this?

Reply With Quote
  #5  
Old March 22nd, 2006, 11:34 AM
underscore underscore is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 1 underscore User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m
Reputation Power: 0
I'm also having this exact problem. Does anyone have a clue what I can do?

Reply With Quote
  #6  
Old May 11th, 2009, 01:26 PM
rowsell rowsell is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 1 rowsell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 31 sec
Reputation Power: 0
var CurrentUrl = document.getElementById('MyIFrame').contentWindow. location.href;

Reply With Quote
  #7  
Old December 1st, 2011, 09:04 AM
brigzy brigzy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 1 brigzy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 24 sec
Reputation Power: 0
Permission denied

Quote:
Originally Posted by rowsell
var CurrentUrl = document.getElementById('MyIFrame').contentWindow. location.href;


I tried the above but get an error -
"Microsoft JScript runtime error: Permission denied"

So although you can navigate - back and forward - it looks like you cannot access the URL.

I suppose itís for security but if you open in a normal browser window you can get the url - so I don't see the point in hiding/protecting it? -


anyone?

Reply With Quote
  #8  
Old December 28th, 2012, 10:29 PM
sajidtoor sajidtoor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 sajidtoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 32 sec
Reputation Power: 0
Thanks for sharing...!

Reply With Quote
  #9  
Old February 18th, 2013, 06:40 AM
jayanta1 jayanta1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 6 jayanta1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 49 sec
Reputation Power: 0
You can try this code:

<html>
<head>
<script type="text/javascript">
<!--
function setSrc(obj, url) {
obj.src = url;
}

function getSrc(obj) {
alert(obj.src);
return obj.src;
}
//-->
// above is the code to get the url from your frame

// now we place that url into the input box:
document.getElementById("frameid").value = myframe; // with frameURL defined earlier
</script>
</head>
<body>
<p><b>|</b>
<a href="#" onclick="javascript:getSrc(document.getElementById('myframe '))">Get src</a> - displays with alert</p>

<iframe id="myframe" src="http://www.google.com"></iframe>
<br>
<br>
<input Id="frameid"><p>frameurl not showing in input</p>
</body>
</html>

Reply With Quote
  #10  
Old January 3rd, 2014, 02:57 AM
xiaoyuandlg xiaoyuandlg is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2013
Posts: 2 xiaoyuandlg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 56 m 44 sec
Reputation Power: 0
Thanks so much for these hearted guys, learnt.

Reply With Quote
  #11  
Old May 23rd, 2014, 11:33 PM
johngates johngates is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2014
Posts: 3 johngates User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 55 sec
Reputation Power: 0
Get url of an iframe

Specifies the URL of the document to embed in the iframe.
Possible values:

Reply With Quote
  #12  
Old May 23rd, 2014, 11:38 PM
johngates johngates is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2014
Posts: 3 johngates User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 55 sec
Reputation Power: 0
Get url of an iframe

Specifies the URL of the document to embed in the iframe.
Possible values:
An absolute URL - points to another web site

A relative URL - points to a file within a web site (like src="default.htm")

to know more go to apphinge.com

Reply With Quote
  #13  
Old May 25th, 2014, 11:13 PM
Fredfdrick Fredfdrick is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2014
Posts: 1 Fredfdrick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 15 sec
Reputation Power: 0
document to embed in the iframe.

Reply With Quote
  #14  
Old May 29th, 2014, 02:17 AM
johngates johngates is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2014
Posts: 3 johngates User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 55 sec
Reputation Power: 0
How do I get the URL of an iframe

As I understand it if you have no control of the frame you are not supposed to know what is going on in this frame. So, knowing it would be a security bug and should be fixed. Browsers are designed to not allow the page spy on what you are doing in another page.
more more infomation click on apphinge.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > How do I get the URL of an iframe


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap