[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Name of page in use in any given frame

Posted on 2011-03-08
4
Medium Priority
?
198 Views
Last Modified: 2012-06-27
Hi,

Is there anyway I can find out the URL currently being displayed in any given frame on a page.

Any help appreciated.

0
Comment
Question by:optidoc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Designbyonyx
ID: 35070185
Using Chrome, you can right click and select "View Frame Source".  When the source code loads, look at the URL... that's your frame page.

In firefox, you can right click -> This Frame -> View Frame Source
0
 

Author Comment

by:optidoc
ID: 35164222
Sorry, should have been more specific -  I was looking for a way of doing it using javascript from within the page, apologies.
0
 
LVL 14

Accepted Solution

by:
Designbyonyx earned 2000 total points
ID: 35165892
Ah, I see.

So you should always be able to get the original SRC of the iframe... meaning the page that was loaded when the iframe was created.  Also, if you change the SRC using javascript, you should be able to get that value.

However, if the user clicks a link INSIDE the iframe, I don't think you can get the new SRC unless the page is being hosted on your domain.  Does that make sense?  Here's an example:

<!-- Example when everything is SAME domain -->
<iframe id="myIFrame" src="some-page.html" />

<script>
// 1) If you change the SRC using javascript, then both of these will give you the current page
// 2) If the user clicks a link in the iframe, then you will have to use the "currentPage" variable
var originalPage = document.getElementById('myIFrame').src;
var currentPage = document.getElementById('myIFrame').contentWindow.location.href;
</script>

Open in new window



<!-- Example when iframe is on different domain -->
<iframe id="myIFrame" src="http://some-domain.com/some-page.html" />

<script>
// The "originalPage" will work, but will always give you the ORIGINAL page name
// If you change the SRC using javascript, the "originalPage" will show you the new URL
var originalPage = document.getElementById('myIFrame').src;

// The "currentPage" will not work for security reasons
// If the user clicks a link in the iframe... you are out of luck
var currentPage = document.getElementById('myIFrame').contentWindow.location.href;
</script>

Open in new window

0
 

Author Closing Comment

by:optidoc
ID: 37314839
Thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question