|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
CSS: using display in NN, FF, Opera
Is There another way to use the....
window.document.all.div.style.display="inline" or "none"; in NN, FF, Opera?? all i would like to do is switch viewing content as what is what the above does, but it doesnt work in anything but IE. does anyone know what i can do?? colton22 |
|
#2
|
||||
|
||||
|
Dom
The way I would do it is
Code:
var all_divs = document.getElementsByTagName('div');
for (var i = 0; i < all_divs.length; i++)
{
all_divs[i].style.display = inline; /* or whatever */
}
|
|
#3
|
||||
|
||||
|
with the above code you supplied, the variable all_divs becomes an array of <div> objects correct?
how can i tell which one is which?? or would i use getElementByID('IDOFDIV'); ? colton22 |
|
#4
|
||||
|
||||
|
Is there a reason you're setting it via scripting?
a global setting in the CSS doesn't suffice? And to jump in on Mittineage's answer... yes, that variable will be an array of ALL div objects on your page. I'm beginning to think there's a simpler solution... Can you show us what it is you're trying to achieve?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#5
|
||||
|
||||
|
i have a prime example...
http://www.freewebs.com/colton22 if you view it in anything other than IE, first you'll get a confirm box asking to continue, click ok to go or cancel to go back, then click on a link, what it does in IE is change the style, display, of certin DIV tags. colton22 |
|
#6
|
||||
|
||||
|
I would be careful how you use this... but check out the script below.
Tested in IE, Firefox, and Opera. Code:
<html>
<head>
<title>Hello World</title>
<script type="text/javascript">
window.onload = function() {
divList = document.getElementsByTagName('DIV');
for (var i=0; i<divList.length; i++) {
divList[i].style.display='inline';
}
}
</script>
</head>
<body>
<div>Hello</div>
<div>Coltron22!</div>
</body>
</html>
*Edit* Oops, Mittineague posted this above... I'll modify mine slightly... gimme a minute. |
|
#7
|
||||
|
||||
|
i finished that part of it
![]() i used ... window.document.getElementById('').style.display="none"; instead. i did have one problem getting there though, i messed up using... getElementByID() instead of getElementById() thanks!! colton22 ps, im just one step closer to having my website avalible to all browsers! ![]() |
|
#8
|
||||
|
||||
|
Check this out... A modified version of my code above.
Adding a class of hello to any DIV causes it to become inline and red. Code:
<html>
<head>
<title>Hello World</title>
<script type="text/javascript">
function hasClassName(element,className) {
var regexp = new RegExp('(^|\\s)' + className + '($|\\s)', 'g');
return (element.className && regexp.test(element.className));
}
window.onload = function() {
divList = document.getElementsByTagName('DIV');
for (var i=0; i<divList.length; i++) {
if ( hasClassName(divList[i], 'hello') ) {
divList[i].style.display='inline';
divList[i].style.backgroundColor='#f00';
}
}
}
</script>
</head>
<body>
<div class="hello">Hello</div>
<div>Coltron22</div>
<div style="display: inline;">From</div> MadCowDzz.
</body>
</html>
This way you can pick and choose which tags to apply the style to... ![]() |
|
#9
|
||||
|
||||
|
alright thanks, i will use this in my code, you may want to submit the hasClassName func above to javascript.internet.com, its very good, lol, it works, so yea and thanks alot man for all the help you have been giving me.
colton22 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > CSS: using display in NN, FF, Opera |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|