SunQuest
 
           JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old September 6th, 2006, 05:08 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
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

Reply With Quote
  #2  
Old September 6th, 2006, 07:13 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 541 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 2 h 15 m 6 sec
Reputation Power: 3
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 */
}

Reply With Quote
  #3  
Old September 7th, 2006, 05:34 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
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

Reply With Quote
  #4  
Old September 8th, 2006, 08:20 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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

Reply With Quote
  #5  
Old September 8th, 2006, 05:07 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
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

Reply With Quote
  #6  
Old September 11th, 2006, 08:40 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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.

Reply With Quote
  #7  
Old September 11th, 2006, 03:25 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
Talking

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!

Reply With Quote
  #8  
Old September 12th, 2006, 10:57 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 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...

Reply With Quote
  #9  
Old September 12th, 2006, 03:00 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - Moderator
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 471 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 9 m 44 sec
Reputation Power: 3
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > CSS: using display in NN, FF, Opera


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway