Solved

jquery display iframe src

Posted on 2011-03-02
2
965 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
ID: 35016696
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
ID: 35028212
Many Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hide Table in merge 3 31
Html Table looping 4 25
On Load function does not trigger on iPhone 4 32
JS Event Does not Trigger From File 2 26
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

856 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