?
Solved

jquery display iframe src

Posted on 2011-03-02
2
Medium Priority
?
969 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
[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 Comments
 
LVL 6

Accepted Solution

by:
hexer4u earned 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

771 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