• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Help deleteing a node at an onload event

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all!!
I'm looking for a solution that i 've came across.
I'm trying to delete a node after an iframe has been created dynamically with the createElement function.
First of all i write in the html document a picture with the message of "loading" and then i create my iframe element and so i can add its attributes.
Once all had been created i append the element to the div where it has to be aligned. Now i use a function of the iframe to call another function where i delete the node of the message "loading".

Here is the code:


All of this code works fine in firefox but testing it on ie doesn't.
I don't know what else could i use to make it work, could someone give me an advice??

Thanks
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am guessing the onload event in IE does not fire.

Eric
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that but just to be sure i did this:



And that worked...but what about the function is there an alternative??
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I read you code the element you are removing is not a child of the element you are telling to remove it from.

Best thing to do is just


Eric
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:If I read you code the element you are removing is not a child of the element you are telling to remove it from.

Best thing to do is just


Eric



This doesn't work...
I was thinking switch to ajax but i don't know if i could get in my innerHTML an iframe.

Anything else?
Thnak you
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought of another solution:

Could i communicate inside of the iframe with the parent window?
Maybe i could write inside of the iframe when the iframe already had been loaded to look for the div that has the "loading" message and then delete it.
But how could i do this? I was looking for how to comunicate between iframes but is a little complicated.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The loading div is not in the iframe with your code example. I am not sure why you keep thinking that "barra" is in the iframe.

Are you getting JavaScript errors in IE? what does it say? What version of IE?

Eric

 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No i know that loading div is not inside of the iframe but i saw this example :
and maybe that could work on an opposite way.
And no i'm not getting errors neither ie7,ie8 or firefox.
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found a way to resolve this issue.
I did it by detecting browser's user name and then applied a lines of codes to that.


Because onload worked with firefox and onreadystatechange in ie7,ie8 i decided to do in this way.
And then worked like i was thinking.

What do you guys think?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about Safari, Opera, Chrome, etc.

Do not browser sniff, code it so they both run.

Eric
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to say it, but browser detection is very amateurish. But sometimes -- especially when dealing with toy browsers like IE -- you have to fork the code to make things work. A better approach is to use feature detection rather than browser detection. That way, youdon;t lock out other browsers.
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what else do you recommend?
How do i implement feature detection?

 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You test for a feature rather than a browser.

The gyrations that need to be accomplished to use cross-browser Ajax is a good example. Professional code will check for the presence of XMLHttpRequest and us it if it exists, and will only resort to using ActiveX for Ajax if that fails and ActiveX is available. Amateurish code will check for IE and specific browsers to check what to do.

By the way, this cross-browser nonsense is largely avoided by using one of the JavaScript library that abstracts it away.
 
Ilh Oleo
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At this point i don't know what are you talking about , .

I'm not using XMLHttprequest since i'm using an iframe. This is becasue it was the only way i found to solve my problem.
Maybe the advice that you are giving me is applied to java but in this case i'm working with php... or it also applies to php?

 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your case you should be able to set both. If the browser fires both, no big deal. Just check to see if the element exists before it is removed.



Eric
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm not using XMLHttprequest ...

It was just an example.
 
reply
    Bookmark Topic Watch Topic
  • New Topic