• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

accessing iFrame elements

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having problems (to say the least) trying to access elements that are held in an iFrame.

I've got some javascript (1) that loads up some xml into an iframe and puts the iframe into a div at the end of the page body.
Another javascript function (2) takes an xml document and works through it using getElementsByTagName() to grab the xml data thats just been loaded.

(Originally javscript (1) loaded the xml into a doc without using an iframe & passed the doc stright into (2), and (2) worked fine. But then I realised the method wouldn't work with the correct security settings in IE 'cos it is calling across domains, so I had to switch to using an iFrame.)

Now the code in (2) can't get to the xml in the iFrame.
(2) starts like this:
function makeSearchResultsTable() {
var myFrame = document.getElementById('tempFrame');
var oppsTags = myFrame.getElementsByTagName("OppsReturned");
...
}

... and using the Firefox DOM inspector, I have a page structure like this:
DIV
|--IFRAME (id=tempFrame)
|-- #document
|--OppSearch
|--OppsReturned
|-- etc...

I need to get this to work in IE6 & Firefox.
Any help would be really appreciated - I've spent hours on this & don't seem to be getting anywhere (except for slowly round the bend ).

Thanks in advance,
Louise
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going across domains with an iframe, you are still going to have the security issues.
 
louise rochford
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this mean I definitively can't load an xml doc from another domain into an iFrame with the default IE6 setting ("Access data sources across domains" set to disable)?

If so, is there any other way around this that you know?

I'm amending a web page for a voluntry organisation, who need the site to be accessable to anyone in the internet, so I was aiming to get it working for IE6 & Firefox as a baseline. If it can't be done, it can't be done, & I'll have to give up. I'd ruled out creating a java web app as the site is currently just a collection of pages 'hosted' on some free space another volunteer has with their ISP. Are there some app server hosting companies out there who could host a small java web app at low cost for a charity?

Very grateful for any ideas.
Many thanks,
Louise
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way it woould be possible to do it across domains if the user had that checkbox set to allow it. To answer your other question, I have no clue.


Eric
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the domain you are reading xml files from is fixed (i.e. they always being read from one place, or some fixed list of palces), than you can use DNS trick.

On you DNS server, you can set:
mydomain.com ip1
subdomain.mydomain.com ip2

than, if you load a page from mydomain.com, and the page has an iframe, with subdomain.mydomain.com, they considered to be from the same domain, even thogh ip will point to different places.

P.S. By the way, I have never tried that
When I read about that it was considered as security threat, that Microsoft refuses to fix.
So if you doing it, let me know how it will work
[ December 13, 2004: Message edited by: Yuriy Fuksenko ]
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic