•
•
•
•
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
![]() |
hello, im guessing this question is quite trivial. i have a page setup as follows.
MAIN PAGE
INNER PAGE
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
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
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
The way you are trying to acquire the parent element is wrong. Do something like this:
html Syntax (Toggle Plain Text)
<html> <head> <script> function remove() { var parent = document.getElementsByTagName('form')[0]; var elem = document.getElementById('id'); var old = (elem.parentNode).removeChild(elem); } </script> </head> <body> <form name="frm"> <iframe id="id" name="name" src="d.html"></iframe> <br /> <input type="button" value="RemoveFrame" onclick="remove();" /> </form> </body> </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."
"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."
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...
'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
•
•
•
•
<iframe id="id" name="name" src="d.html"></iframe>
-- 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
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Instead of removing it, why not just hide it.
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.
.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
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.
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."
"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."
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- STL vector - deleting the last element (C++)
- removing an element... (C)
- remove method linked list (C)
- Stripping the last element off an array (Perl)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Realtime input field update
- Next Thread: I have a link wich opens a the second page with links wich call a javascript functio



Linear Mode