Author Topic: Fontsize changing (js) by id (html tag) will not work proper help needed  (Read 7298 times)

0 Members and 1 Guest are viewing this topic.

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Hi,

i have this js (put in root/js/fontsize.js):

Code: [Select]
//<!-- Textgroesse anfang -->
var faktor = 0.05;
var start_groesse = 1.0;
var anz = 0;
function fontsizer(inc, reset) {
if ((anz + inc >= 0) && (anz + inc <= 2)) {
anz += inc;
neue_groesse = anz * faktor + start_groesse;
artikel_text = document.getElementById('container');
artikel_text.style.fontSize = neue_groesse + "em";
}
switch (anz) {
case 0:
document.getElementById("fsminus").src = "templates/Iceberg/images/fontsize_down_inactive.png";
break;
case 2:
document.getElementById("fsplus").src = "templates/Iceberg/images/fontsize_up_inactive.png";
break;
default:
document.getElementById("fsplus").src = "templates/Iceberg/images/fontsize_up.png";
document.getElementById("fsminus").src = "templates/Iceberg/images/fontsize_down.png";
break;
}
}
//<!-- Textgroesse ende -->


in header.html:

Code: [Select]
<script language="javascript" src="./js/fontsize.js"></script>
in any template.html:

Code: [Select]
<a href="javascript:void(0)" onmousedown="fontsizer(-1, false)" onfocus="blur()"><img src="{template_url}/images/fontsize_down.png" id="fsminus" border="0"></a>
<img src="{template_url}/images/fontsize_font.png" id="fsminus" border="0"></a>
<a href="javascript:void(0)" onmousedown="fontsizer(1, false)" onfocus="blur()"><img src="{template_url}/images/fontsize_up.png" id="fsplus" border="0"></a>

I've set the id to change the fontsize to "container" this is my main div for the hole galery...
But only some custom text in the footer changes his fontsize... (not the copyright text)

I thought the main div inherits to sub divs?

If not how to handle this with the js? is there an easy way without set an individual id to any tag
i like to change the fontsize?


Greetz X23

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Fontsize changing (js) by id (html tag) will not work proper help needed
« Reply #1 on: October 20, 2010, 04:42:29 AM »
I thought the main div inherits to sub divs?
It does unless overridden by it's own style.
Try DOM Inspector or FireBug firefox extensions to see what HTML element has what style and via what style class.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline x23piracy

  • Sr. Member
  • ****
  • Posts: 420
    • View Profile
    • FHG
Re: Fontsize changing (js) by id (html tag) will not work proper help needed
« Reply #2 on: October 22, 2010, 10:50:13 PM »
I thought the main div inherits to sub divs?
It does unless overridden by it's own style.
Try DOM Inspector or FireBug firefox extensions to see what HTML element has what style and via what style class.

Hi v@no,

is it possible to get all the available style classes names and override there fontsize style
settings with my existing script?

getelementbyclass don't exists?

Sorry im very bad with js...

EDIT:

I found this code on the web that should find all tags that have an id and save them
into var "element", can you help with biulding a working js im to dump for doing that alone.

the code:

Code: [Select]
var element=new Array()

for (var i=0;i<document.getElementsByTagName('*').length;i++)
{
if (document.getElementsByTagName('*')[i].id)

{element[document.getElementsByTagName('*')[i].id]=document.getElementsByTagName('*')[i]}
}


Here is my idea:

Code: [Select]
//<!-- Textgroesse anfang -->
var faktor = 0.05;
var start_groesse = 1.0;
var anz = 0;
var element=new Array()

for (var i=0;i<document.getElementsByTagName('*').length;i++)
{
if (document.getElementsByTagName('*')[i].id)

{element[document.getElementsByTagName('*')[i].id]=document.getElementsByTagName('*')[i]}
}
 
function fontsizer(inc, reset) {
if ((anz + inc >= 0) && (anz + inc <= 2)) {
anz += inc;
neue_groesse = anz * faktor + start_groesse;

HERE THE LOOP SHOULD START

artikel_text = document.getElementById('container');
artikel_text.style.fontSize = neue_groesse + "em";

HERE THE LOOP SHOULD STOP

}
switch (anz) {
case 0:
document.getElementById("fsminus").src = "templates/Iceberg/images/fontsize_down_inactive.png";
break;
case 2:
document.getElementById("fsplus").src = "templates/Iceberg/images/fontsize_up_inactive.png";
break;
default:
document.getElementById("fsplus").src = "templates/Iceberg/images/fontsize_up.png";
document.getElementById("fsminus").src = "templates/Iceberg/images/fontsize_down.png";
break;
}
}
//<!-- Textgroesse ende -->

If that is delphi i should write:

Code: [Select]
var
  I : Integer;
for I := 0 to length(element) do
begin
  artikel_text = document.getElementById(element[I]);
  artikel_text.style.fontSize = neue_groesse + "em";
end;


Greetz X23
« Last Edit: October 22, 2010, 11:04:52 PM by x23piracy »

Don't trust in md5 it's unsafe change your 4i galerys password hash algorythm! second pw db field, create new hashes over some time, deny old hash. Help members that cry, send informationen mail to the rest. Camouflage new pw hash in cookie. Done!

--(◔̯◔)--