aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Help deleteing a node at an onload event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Help deleteing a node at an onload event" Watch "Help deleteing a node at an onload event" New topic
Author

Help deleteing a node at an onload event

Ilh Oleo
Ranch Hand

Joined: Feb 07, 2007
Posts: 57
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
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I am guessing the onload event in IE does not fire.

Eric
Ilh Oleo
Ranch Hand

Joined: Feb 07, 2007
Posts: 57
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
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Feb 07, 2007
Posts: 57
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

Joined: Feb 07, 2007
Posts: 57
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
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Feb 07, 2007
Posts: 57
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

Joined: Feb 07, 2007
Posts: 57
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
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What about Safari, Opera, Chrome, etc.

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

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ilh Oleo
Ranch Hand

Joined: Feb 07, 2007
Posts: 57
So what else do you recommend?
How do i implement feature detection?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

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

Joined: Feb 07, 2007
Posts: 57
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
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

I'm not using XMLHttprequest ...
It was just an example.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help deleteing a node at an onload event