| | |
Disapearing DIV
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 257
Reputation:
Solved Threads: 20
Hi,
I have created a login box that appears on the click of a button that says login (Obviously) but when I load the page the div appears until the page loads. How do I get the div to appear immediately?
You can see the page here or http://freeform.ath.cx
Regards,
Sam Rudge
I have created a login box that appears on the click of a button that says login (Obviously) but when I load the page the div appears until the page loads. How do I get the div to appear immediately?
You can see the page here or http://freeform.ath.cx
Regards,
Sam Rudge
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
Join Date: May 2008
Posts: 257
Reputation:
Solved Threads: 20
•
•
•
•
Well Sam,
Remove:onload="javascript:hidebox()"from your BODY element and you're OK to go.
(the part i red of the following html code in your document)
<body onload="javascript:hidebox()">
Cheers
Regards,
Sam Rudge
P.S. Thanks for helping
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
1. You can:
you're a go!
p.s.: Remove the
Cheers
Set your initial login box visibility to: hidden.2.Or do it the "right way"
Your css#yourLoginboxID{visibility:hidden}.
:]
Leave the code as is right now (that is remove the body "onload function call" - as I said in my previous post) and append this function callhidebox()to your external js file, right after the "function hidebox()" end.
you're a go!
p.s.: Remove the
<body onload="javascript:hidebox()"> from all other pages using it.Cheers
Last edited by Troy III; Jul 25th, 2008 at 10:49 am.
•
•
Join Date: May 2008
Posts: 257
Reputation:
Solved Threads: 20
•
•
•
•
2.Or do it the "right way":]
Leave the code as is right now (that is remove the body "onload function call" - as I said in my previous post) and append this function callhidebox()to your external js file, right after the "function hidebox()" end.
This is my javascript from logbox.js
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
// Javascript for showing the log in box: //Hide function hidebox() { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('LoginBox').style.visibility = 'hidden'; } else { if (document.layers) { // Netscape 4 document.LoginBox.visibility = 'hidden'; } else { // IE 4 document.all.LoginBox.style.visibility = 'hidden'; } } } hidebox(); //Show function LoginBox() { if (document.getElementById) { // DOM3 = IE5, NS6 document.getElementById('LoginBox').style.visibility = 'visible'; } else { if (document.layers) { // Netscape 4 document.LoginBox.visibility = 'visible'; } else { // IE 4 document.all.LoginBox.style.visibility = 'visible'; } } }
Regards,
Sam Rudge
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
Well,
use innerHTML property.
use innerHTML property.
javascript Syntax (Toggle Plain Text)
// Javascript for showing the log in box: //Hide function hidebox() { var loginDiv = document.getElementById('LoginBox'); loginDiv.innerHTML = ""; } //Show function LoginBox() { var loginDiv = document.getElementById('LoginBox'); loginDiv.innerHTML = "Your login div inner HTML as String"; }
When you think you have done a lot, then be ready for YOUR downfall.
•
•
Join Date: May 2008
Posts: 257
Reputation:
Solved Threads: 20
Could You Explain This More.
Regards,
Sam Rudge
Regards,
Sam Rudge
My Blog, Life and everything that matters to me - SamRudge.co.uk
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
2x Macbook Pro's, 1x Mac Pro, 1x iMac, 2x Macbook's running Fedora linux - In conclusion, I hate windows =)
•
•
•
•
Right i have done that but now the box doesn't disappear at all
-How about replacing your old js file with this one on the server?
Or, how about replacing that long oldfashion conditional with something compact like this:
One thing I forgot to tell you is that you should never link your script files in the document head if your aim is to manipulate dom style and similar during load time that is on before load event. Placing scripts on document head was allowed because of content prelloading scripts. Script tag is legitimate body element. So this script should also be linked somewhere before the body end tag.
p.s.: not to forget, you should also update the new function name at the lines of function call with the new one. ...showBox(), instead of LoginBox() because that name is now reserved for global var.
Cheers
var LoginBox =
/*IE4*/ LoginBox||
/*NN4*/ document.LoginBox||
/*W3C*/ document.getElementById('LoginBox');
LoginBox=LoginBox.style||LoginBox;
function hidebox(){
LoginBox.visibility="hidden";
}
function showBox(){
LoginBox.visibility="visible"
}
hidebox();One thing I forgot to tell you is that you should never link your script files in the document head if your aim is to manipulate dom style and similar during load time that is on before load event. Placing scripts on document head was allowed because of content prelloading scripts. Script tag is legitimate body element. So this script should also be linked somewhere before the body end tag.
p.s.: not to forget, you should also update the new function name at the lines of function call with the new one. ...showBox(), instead of LoginBox() because that name is now reserved for global var.
Cheers
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Looking for code in ajax for dropdownlist date.
- Next Thread: expanding block script works in safari - not in firefox 3
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate api automatically blackjack browser bug calendar captchaformproblem checkbox child class close cookies createrange() cursor dependent disablefirebug dom dropdown editor element embed engine events explorer ext file firehose flash form forms game google gxt hiddenvalue highlightedword html htmlform ie8 iframe image() images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math matrixcaptcha media microsoft object onerror onmouseoutdivproblem onreadystatechange parent paypal pdf php player post progressbar rated regex runtime scroll search security session shopping size software sql star stars stretch synchronous text textarea tweet twitter unicode validation web webservice website window windowsxp wysiwyg \n





