CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 3rd, 2003, 03:07 AM
spstieng spstieng is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Australia, but soon Norway
Posts: 3 spstieng User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Display "dynamic" text and CSS link problem

I want to display some text when a user clicks my menu selections.
Table 1 = The menu
Table 2 = where the text is to be displayed.

Inside Table 2 I have e.g: (the text is hidden by default)
<div id="someText1" style="display:none;"> This is the text. Lots of text </div>


Inside Table 1 I have
<a href=# onMouseDown="show('someText1'); return true;"> Menu Item 1 </a>

This works with the follwing script:
function flip(foo) {
//document.getElementById(foo).style.visibility="hidden";
if( document.getElementById(foo).style.display == "none") {
document.getElementById(foo).style.display="block";
} else {
document.getElementById(foo).style.display="none";
}
}
function show(foo) {
document.getElementById(foo).style.display="block";
return true;
}
function hide(foo) {
document.getElementById(foo).style.display="none";
return true;
}
===========================================
*Now*, I have 5 menu items, and a lot of text is to be displayed for each of them. I want to avoid having a mile long webpage (in code that is) and I want to try not to create 5 different html pages.

Is there a way where I can retrieve the text from somewhere and display it to the user WITHOUT reloading the page????
I tried using variables and document.write function.... kind of worked, but then only the text was displayed, and nothing else of the page (new page with text).
How can I solve this??
**********************************************
CSS PROBLEM.

This works. (External file)

.MenuText
{
color: #4488E9;
font-size: 75%;
font-weight: bold;
text-decoration: none
}
a:link { text-decoration: none; color: #4488E9 }
a:hover { color: #1329D0; font-weight: bold }

This doesn't work.

a.MenuText:link { text-decoration: none; color: #4488E9 }
a.MenuText:hover { color: #1329D0; font-weight: bold }

Comments?
***************************************

Hope I explained myself good enough. Any suggestions appreciated!

Steven

Last edited by spstieng : June 3rd, 2003 at 03:16 AM.

Reply With Quote
  #2  
Old June 3rd, 2003, 04:22 AM
icy_polecat's Avatar
icy_polecat icy_polecat is offline
Senior Polecat
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Jersey (the original version)
Posts: 210 icy_polecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 57 sec
Reputation Power: 10
Send a message via Yahoo to icy_polecat
Hi spstieng,

Just to be confusing I'm gonna answer (or try to) these backwards.

CSS - Problem

Right, your CSS DOES work but only if you are really specific about where you specify the class. This style will only work if applied directly to the <a> element of your code i.e.:

<a href="#" class="MenuText">Testing 123</a>

Apllying the class to a P element or anything like that won't work as you are specifically targetting an <a> parent (CSS inheritency - aka a brain freeze waiting to happen!)

If you want to apply the style to all links contained within a body of text with the menu text class you need to rearrange your css:

.MenuText a:link { text-decoration: none; color: #4488E9; }
.MenuText a:hover { color: #1329D0; font-weight: bold; }

This will mean any links within the text with the class MenuText will have your style applied.

It's also worth warning you (although you probably know this) that there is something of a gotcha involved in using CSS pseudo classes. You have to make sure they are in the right order. In this example you are probably ok but for a more complex style (with visited and active styles) you must use the following order in your style sheet:

a:link
a:visited
a:hover
a:active

I hope this makes sense.

As for the second problem:

JavaScript isn't really my strong suit but from the sounds of it you could use an IFrame or layer. these can have a SRC element setting just like an image. That SRC can be a HTML doc residing on your server. You will need to experiment with the code to get it to work in all browsers (if you are targeting anything less than NN4 then forget it!) but this should work without too much hassle. I frames are for IE and NN 6+ whilst you need to use LAYER or ILAYER for NN4.

I can't really think of an alternative that doesn't involve a refresh. But to be honest with you, text data is relatively small so provided you code your divs at the bottom of your page (to allow more relevant content to load first) then you will notice a very small performance hit. Most dial up users can download the entire works of Shakespeare in just over 60 seconds so I don't think a few menu options are going to cause them too much trouble :-)

I hope this is helpful.

Icy

Reply With Quote
  #3  
Old June 3rd, 2003, 04:36 AM
spstieng spstieng is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Australia, but soon Norway
Posts: 3 spstieng User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Icy, that helped my CSS problem (and no, I didn't know the ordering mattered!)

Still the javascript. The reason is that the code will be VERY long and difficult to maintain.

Do you (or anyone else) know if I can show and hide contents of a variable?
E.g. var txt1 = 'some text';

And then call the show function with the variable name? -> show(txt1).

If that is possible, I'll just chuck my text in an external *.js file and just link it in my main document.

Steven

Reply With Quote
  #4  
Old June 3rd, 2003, 04:58 AM
icy_polecat's Avatar
icy_polecat icy_polecat is offline
Senior Polecat
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Jersey (the original version)
Posts: 210 icy_polecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 57 sec
Reputation Power: 10
Send a message via Yahoo to icy_polecat
right with you (sorry i can be a bit slow on the uptake sometimes!)

As I said I'm no Javascript expert but I do know that you can set the inner HTML of a Span tag dynamically. Unfortunately I seem to have lost the example i had of this. Other than that I'm afraid I will have to let someone else sort this one out before my lame JScript knowledge embaresses me in front of the entire forum.

Icy

Reply With Quote
  #5  
Old June 3rd, 2003, 06:18 AM
spstieng spstieng is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Australia, but soon Norway
Posts: 3 spstieng User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yea, u're a real lamer Ice

Nah! Thanks so much for your help.
I'm diching Javascript - never liked it anyway. I'll practive my PHP skills instead

Steven

Reply With Quote
  #6  
Old June 3rd, 2003, 09:24 PM
shp shp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 17 shp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In case you haven't completely given up on the idea, there is some very simple code for changing content at http://www.dyn-web.com/dhtml/lyr-cnt/innerhtml.html . More writing to layers examples at http://www.dyn-web.com/dhtml/write-lyrs.html

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Dispay "dynamic" text and CSS link problem

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap