Solved

jquery display iframe src

Posted on 2011-03-02
2
957 Views
Last Modified: 2012-06-21
Hello Experts,

I have an iframe whose src changes.

ie
<a href="#" onClick="$('#login').show();">Show login</a>
<iframe id="login" src="login.php" width="500" height="200" />

Although it starts of as login.php - the user (in the login screen) may decide to load up forgot-password.php or new-user.php (to create a new account).  They load either of these screens by clicking on a link inside login.php. This action refreshs the 'screen' inside the iframe with the correct php page.  

I want to call a piece of code (using jQuery) that will tell me the name of this screen.
I would have thought when the user clicks into the forgot password/new user page - it would in turn change the 'src' tag from login.php to whatever the current screen in the iframe is - however, I'm not sure.  

Is this possible to achieve?
0
Comment
Question by:jagku
2 Comments
 
LVL 6

Accepted Solution

by:
hexer4u earned 500 total points
Comment Utility
Yes.
jQuery(function(){
		jQuery('iframe').load(function(){//each time this is called, the frame reloaded
			var current_src = jQuery(this).attr('src');
			var current_body = $('#iframeID').contents().find('body');
			alert(current_body.html());//shows the HTML code inside the <body></body>
		});
	});

Open in new window

0
 

Author Closing Comment

by:jagku
Comment Utility
Many Thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now