Schriftgrösse Veränderung begrenzen
Anderl72
- javascript
0 wahsaga
Hallo
Ich benutze ein Javascript zur Vergrösserung- und kleinerung der Schriftgrösse. Nun soll jedoch die Vergrösserung begrenzt werden auf max 130 oder 140%.
Ich benutze folgendes script:
******************************************************************
/*
Easydynfont
Version 1.0
written by Chris Heilmann
please refer to the homepage at http://www.onlinetools.org/tools/easydynfont.php
*/
// Standard setting, separate fonts with "," and make sure to set standardfont
// and size to avoid errors
var fonts="Schriftgrösse: "
var standardfont="Arial"
var standardsize="100%"
var nosave=false;
/*
function drawform()
adds the standard form to the document.
*/
function drawform(){
if (!document.layers){
document.write("<form action="/" name="fontform" class="accesskey2">");
document.write("<a accesskey="8" title="[Alt+8] Schrift grösser" class="accessgroup2" href="javascript:addSize(10)" value="Schrift grösser" />Schrift grösser");
document.write("<a accesskey="9" title="[Alt+9] Schrift kleiner" class="accessgroup2" href="javascript:addSize(-10)" value="Schrift kleiner" />Schrift kleiner");
document.write("</form>");
}
}
/*
function init()
loads the cookiedata and changes the document accordingly, if there is no
cookie, sets the standard settings and stores it
*/
function init(){
if (screen.width >= "1024")
standardsize = "100%";
if (screen.width <= "800")
standardsize ="80%";
if (!document.layers){
size=getCookie("kreisbehindertenportal-Goeppingen.de");
if (size!=null){
c=size.split(":");
document.getElementsByTagName("body").item(0).style.fontSize=c[0];
document.getElementsByTagName("body").item(0).style.fontFamily=c[1];
}
if (size==null || c[0]=="" || c[1]==""){
document.getElementsByTagName("body").item(0).style.fontSize=standardsize;
document.getElementsByTagName("body").item(0).style.fontFamily=standardfont;
storeSize()
}
}
}
/*
function addSize(add)
increases the size of the document font by "add", negative values make the
font smaller.
*/
function addSize(add){
if (!document.layers){
doc = document.getElementsByTagName("body").item(0)
size=parseInt(doc.style.fontSize)+add;
doc.style.fontSize=size+"%";
if (nosave==false) storeSize()
}
}
/*
function SetSize(add)
sets the font size of the document.
*/
function setSize(add){
if (!document.layers){
document.getElementsByTagName("body").item(0).style.fontSize=add+"%";
if (nosave==false) storeSize()
}
}
/*
function SetFont(add)
sets the font face of the document.
*/
function setFont(add){
if (!document.layers){
doc = document.getElementsByTagName("body").item(0)
doc.style.fontFamily=add;
if (nosave==false) storeSize()
}
}
function storeSize(){
var exp = new Date();
exp.setTime(exp.getTime() + 24*60*60*90*1000);
size=document.getElementsByTagName("body").item(0).style.fontSize
setCookie("kreisbehindertenportal-Goeppingen.de",size+":",exp);
}
/*
function setCookie()
sets the cookie
*/
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
document.cookie = curCookie
}
/*
function getCookie()
reads the cookie
*/
function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex +
prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex +
prefix.length,
cookieEndIndex))
}
******************************************************
Wer kann mir dabei helfen?
Danke und Gruss
Anderl
hi,
Ich benutze ein Javascript zur Vergrösserung- und kleinerung der Schriftgrösse. Nun soll jedoch die Vergrösserung begrenzt werden auf max 130 oder 140%.
Ich benutze folgendes script:
dann solltest du mal versuchen zu verstehen, was das script überhaupt macht.
tipp: für das letztendliche neu setzen der schriftgrösse scheint mir die funktion addSize() verantwortlich - wenn du eine abfrage, ob deine gewünschte maximalgrösse erreicht ist, dann am besten hier.
gruss,
wahsaga