473,804 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Iframe content change detection

7 New Member
Hi guys
We have a requirement like in one iframe we have to show one site and in another iframe we have to show some other external site, we did it using

[HTML]
<iframe src="http://www.a.com"> </iframe>
<iframe src="http://www.b.com"> </iframe>
[/HTML]

now if the session expires in any one site, the login page is shown in only the correponding iframe, what we require is that the login page has to be shown in the entire window(since both have the same credentials) instead of an Iframe,

We thought of a javascript which should run after each content change of iframe
and we will be checking the content present in the corresponding iframe for loginpage contents, if it contains the loginpage we will be setting the window location to login page.

What we need is the way to run a javascript after the content got changed in a iframe(External site contents).

Your Help is highly appreciated
Dec 6 '07 #1
9 18494
acoder
16,027 Recognized Expert Moderator MVP
If the iframe and the main page are from different domains, this will not be possible with JavaScript.
Dec 6 '07 #2
dangroza
13 New Member
jad2006, did you found a solution? I can think of some other ways using AJAX ..

Dan
Dec 6 '07 #3
jad2006
7 New Member
Hi Dan/Acoder

I found a solution using javascript.Foll owing is the code
[HTML]


<iframe src="http://www.a.com"> </iframe>
<iframe src="http://www.b.com" name="frame2" onLoad="javascr ipt:checkForLog inPage()"> </iframe>

[/HTML]

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function checkForLoginPage(){
  3. var ad=frame2.document;
  4.  
  5. if(ad!=null)
  6. var bodyText= ad.getElementsByTagName("body").item(0).innerHTML;
  7. //as my loginpage contains this text
  8. if(bodyText.indexOf('Forgot your Password?')>0){
  9. //clear the cookies
  10. //set window.location to login page;
  11.  
  12. window.location.href=loginurl;
  13. }
  14. }
  15. </script>         
  16.  
  17.  
Dan,
Please Share the Solution u r thinking of..

Thanks & Regards
Jad
Dec 7 '07 #4
Dasty
101 Recognized Expert New Member
Hi Dan/Acoder

I found a solution using javascript.Foll owing is the code
[HTML]


<iframe src="http://www.a.com"> </iframe>
<iframe src="http://www.b.com" name="frame2" onLoad="javascr ipt:checkForLog inPage()"> </iframe>

[/HTML]

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function checkForLoginPage(){
  3. var ad=frame2.document;
  4.  
  5. if(ad!=null)
  6. var bodyText= ad.getElementsByTagName("body").item(0).innerHTML;
  7. //as my loginpage contains this text
  8. if(bodyText.indexOf('Forgot your Password?')>0){
  9. //clear the cookies
  10. //set window.location to login page;
  11.  
  12. window.location.href=loginurl;
  13. }
  14. }
  15. </script>         
  16.  
  17.  
Dan,
Please Share the Solution u r thinking of..

Thanks & Regards
Jad
This is not gonna work. You just can not access document's properties/mothods when iframe got external (from different domain) page loaded (as you said). acoder is right
Dec 7 '07 #5
dangroza
13 New Member
Hello jad2006,
I thought using that method also, but what I get on both Firefox and IE(the browsers that I usually test on) is the following exception:
"Permission denied to get property HTMLDocument.ge tElementsByTagN ame" when trying to get content from iFrame.
Am I missing something?

Dan
Dec 7 '07 #6
dangroza
13 New Member
I see Dasty already replied to that. Other methods that I can think of (using AJAX) require some extra coding on both websites that you display(I consider this important as a measure of security on a website - client side scripting can create vulnerabilities on your website).

jad2006, can you tell more about the content you are showing in this pages?

Dan
Dec 7 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Hi Dan/Acoder

I found a solution using javascript.Foll owing is the code
[HTML]


<iframe src="http://www.a.com"> </iframe>
<iframe src="http://www.b.com" name="frame2" onLoad="javascr ipt:checkForLog inPage()"> </iframe>

[/HTML]<snipped>
The only way this would work is if the main page is from domain b.com.
Dec 10 '07 #8
jad2006
7 New Member
Sorry guys
I simply tested it by using giving some static pages in Iframe1 and iframe2 , I have not tested in the real scenario, I am wrong,Thanks everyone for ur valuable suggestios, but is there any way out to do this?
Dec 12 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
You could use a web proxy via Ajax. Use server-side code to get the contents, then return the response to the client-side.
Dec 13 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

11
41218
by: HolaGoogle | last post by:
Hi, Sorrryy to ask such basic question but i do need your help! Here's what i'm trying to do: In my parent form i'm calling a my Iframe form to get certain value, then depending on that value enable or disable my submit button in my parent form without using any refresh/reload or submit button in my form. Looks realy simple but i don't know how to get it work. actualy, i've been able to populate listbox,text boxes in my parent with...
4
7622
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I fill the iframe with content (<body> tag and so on and also insert a <div> tag, inbetween is the content that should be modified). Now if the event "overflow" or "underflow" is triggered the iframe
3
8136
by: Russell | last post by:
I have a quirky issue that I believe involves timing and only 2 hairs left to pull. I have a modal dialog that is an IFrame. The IFrame contains another window - which contains the appropriate title. I am trying to change the title of the IFrame window to be that of the contained window title. If I uncomment the alert statement below - the title change works. Comment out the alert - and - no title change.
9
3735
by: cakewalkr7 | last post by:
We have a form that contains an iframe. In the iframe are 3 select boxes (country, state and city). When you select the country, the iframe page refreshes with the appropriate states and does the same thing when you select a state. We did some testing in the different browsers with this method and it appeared that the only browser that it worked reliably in was IE. So, we put some asp code in that ran a browser check and displayed the...
6
9396
by: paul | last post by:
HI! How do we send a variable from an Iframe page back to its parent? I have a script that calculates the iframe's window size but I need to know how to send that value back to its parent so I can use it there. Thanks in advance :) Paul
3
4495
by: PCgeek | last post by:
sorry moved this over to javascript forum, didn't mean to post 2x! Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and so that the music doesn't reload each time a page is switched. There is another javascript to resize...
2
3284
riptide2049
by: riptide2049 | last post by:
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to quicktime or windows meida player depending on which plugin was found. after the plug in is found a iframe with the right player is created. here is the code. for some reason In IE the plug in doesnt work and in fire fox it crashes <!DOCTYPE html...
1
1543
by: CJ4R | last post by:
Have an issue with an iframe in FF blocking links in a z-index layer behind the layer containing the iframe. It works in IE. I can't change the layer index of the iframe because it's content needs to be on top all the time. Whenever the user mouseovers that iframe content it should expand to full size. I haven't figured out how to change the height of the ifrmae from Doc2. It should be something like... ...
0
9712
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.