User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,547 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 5146 | Replies: 5
Reply
Join Date: Apr 2007
Location: Birmingham
Posts: 368
Reputation: Fungus1487 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 35
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Whiz

remove element

  #1  
Jul 4th, 2007
hello, im guessing this question is quite trivial. i have a page setup as follows.

MAIN PAGE
<html>
  <head>
  </head>
  <body>
    <div id='innerlogin'><iframe src='INNER PAGE'></iframe></div>
  </body>
</html>

INNER PAGE
<html>
  <head>
    <script type="text/javascript">
      function RemoveDiv(){
      d = parent.document.body;
      d_nested = parent.document.getElementById("innerlogin");
      throwaway = d.removeChild(d_nested);
      }
    </script>
   </head>
   <body>
     ........
   </body>
</html>

now i am using asp.net and after all has been said and done with the INNER PAGE i would like to fire off the javascript 'RemoveDiv' to get rid of the div and the inner page. i realise this could be done using asp.net and no javascript at all. but my page is already heavily consistent of controls and i wish to remove the strain of the server as much as possible and allow the client to take care of presentation.

the problem is this does not work as you may have guessed so can anybody spot what ive done wrong ? or am i doing it completely wrong
Last edited by Fungus1487 : Jul 4th, 2007 at 9:55 am.
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,811
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: remove element

  #2  
Jul 4th, 2007
The way you are trying to acquire the parent element is wrong. Do something like this:

  1. <html>
  2. <head>
  3. <script>
  4. function remove()
  5. {
  6. var parent = document.getElementsByTagName('form')[0];
  7. var elem = document.getElementById('id');
  8. var old = (elem.parentNode).removeChild(elem);
  9. }
  10. </script>
  11. </head>
  12. <body>
  13. <form name="frm">
  14. <iframe id="id" name="name" src="d.html"></iframe>
  15. <br />
  16. <input type="button" value="RemoveFrame" onclick="remove();" />
  17. </form>
  18. </body>
  19. </html>
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Apr 2007
Location: Birmingham
Posts: 368
Reputation: Fungus1487 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 35
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Whiz

Question Re: remove element

  #3  
Jul 4th, 2007
i understand that this will work when you have an element on the page that contains the IFRAME but what im looking to achieve is to remove the div containing the iframe from within the iframe itself so where you have specified...
<iframe id="id" name="name" src="d.html"></iframe>
'd.html' would contain the button to close the div which is holding the iframe it is currently in. hah ive just even confused myself. maybe this will help.

-- MAINPAGE.html
---- DIV
------ IFRAME
-------- d.html
---------- onclick delete DIV ^^^

thanks for the help
Last edited by Fungus1487 : Jul 4th, 2007 at 6:34 pm.
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote  
Join Date: Jan 2007
Posts: 2,537
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 107
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: remove element

  #4  
Jul 13th, 2007
Instead of removing it, why not just hide it.

.stealth {visibility: visible;}

Then, at the point where you want something to disappear, change its visibility attribute to:

hidden - if it should still take up the space.

collapse - if it should disappear from the page format too.
Daylight-saving time uses more gasoline
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,811
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 339
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: remove element

  #5  
Jul 14th, 2007
Midimagic, you are getting confused between the 'display' attribute and 'visibility' attribute of CSS. Visibility attribute never removes the element from the page, it just hides it. It still influences the page layout and takes up space.

The difference between 'hidden' and 'collapse' is that 'collapse' works on normal as well as table elements, whereas 'hidden' works only for normal elements.

Fungus, I gave you a working sample code which nearly does what you want to do. If you want further help you have to at least try out something and paste it here and tell me what is not working.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Jan 2007
Posts: 2,537
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 107
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: remove element

  #6  
Jul 17th, 2007
I'm not confused. I just find it easier to hide an element, as opposed to totally removing it.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 3:36 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC