Manipulering af fontstørrelse
Jeg har en lille javascript funktion, som jeg VED virker. Mit problem er at jeg nu vil have den smidt ind i et dokument, der oprindeligt at lavet med MS Word. (Gyyyys - jeg ved det.)Når jeg prøver at lægge det på, virker det ikke mere, men jeg kan ikke gennemskue hvorfor.
Funktionen forsøger at finde <div> tag med id broedtekst, og vil så ændre fontstørrelsen på det den indeholder.
Funktionen ser således ud, og kaldes onload:
-----------------------------------------------
function checkFontSize() {
fontsize = (fontsize * window.screen.height / 600);
var i = "" + fontsize;
if (i.indexOf(".") > 0) {
i = i.substr(0,i.indexOf("."));
}
fontsize = i;
document.getElementById('broedtekst').style.fontSize=fontsize;
}
-----------------------------------------------
Den fungerer fint i et .htm doc jeg selv har lavet. En lille forskel er at der her kun er ET div tag med korrekt id. I nedenstående eksempel er der TO, hvor det ene er nestet inde i det andet, og det er det inderste jeg vil have fat i.
Et eksempel på et doc kunne være som følger:
-----------------------------------------------
<html xmlns:v="urn:schemas-microsoft-com:vml"xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:w="urn:schemas-microsoft-com:office:word"xmlns="http://www.w3.org/TR/REC-html40">
<head>
<script language="JavaScript" src="/jscript/tekst.js"></script>
<style type=text/css>
html { margin: 0px; }
@font-face { font-family: Via Sign Regular; font-style: normal;
font-weight: normal;
div.indhold { font-family: 'Via Sign Regular', ViaRegular, Verdana, Helvetica, Arial;
background-color: #000000;
color: #FFFFFF;
cursor: text;
overflow: hidden;
margin : 0px;
margin-left: 10px; }
</style>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document><meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="WedMay19143352CEST2004-942365055-filer/filelist.xml">
<link rel=Edit-Time-Datahref="WedMay19143352CEST2004-942365055-filer/editdata.mso">
<title>Test skabelon</title>
<!--[if gte mso 9]>
<xml>
<o:DocumentProperties>
<o:Author>rv</o:Author>
<o:LastAuthor>rv</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>0</o:TotalTime>
<o:Created>2004-05-19T12:33:00Z</o:Created>
<o:LastSaved>2004-05-19T12:33:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>4</o:Words>
<o:Characters>29</o:Characters>
<o:Company>DSB</o:Company>
<o:Lines>1</o:Lines>
<o:Paragraphs>1</o:Paragraphs>
<o:CharactersWithSpaces>32</o:CharactersWithSpaces>
<o:Version>10.4219</o:Version>
</o:DocumentProperties>
</xml>
<![endif]-->
<!--[if gte mso 9]>
<xml>
<w:WordDocument>
<w:SpellingState>Clean</w:SpellingState>
<w:HyphenationZone>21</w:HyphenationZone>
<w:Compatibility><w:BreakWrappedTables/>
<w:SnapToGridInCell/><w:WrapTextWithPunct/>
<w:UseAsianBreakRules/></w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml>
<![endif]--><style><!--/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:12.0pt;font-family:"Times New Roman";mso-fareast-font-family:"Times New Roman";}@page Section1{size:595.3pt 841.9pt;margin:3.0cm 2.0cm 3.0cm 2.0cm;mso-header-margin:35.4pt;mso-footer-margin:35.4pt;mso-paper-source:0;}
div.Section1{page:Section1;}--></style>
<!--[if gte mso 10]><style>/* Style Definitions */table.MsoNormalTable{mso-style-name:"Tabel - Normal";mso-tstyle-rowband-size:0;mso-tstyle-colband-size:0;mso-style-noshow:yes;mso-style-parent:"";mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-para-margin:0cm;mso-para-margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:10.0pt;font-family:"Times New Roman";}
</style>
<![endif]-->
<!--[if gte mso 9]>
<xml>
<o:shapedefaults v:ext="edit" spidmax="2050"><o:colormru v:ext="edit" colors="#003"/>
<o:colormenu v:ext="edit" fillcolor="#003"/></o:shapedefaults>
</xml>
<![endif]--><!--[if gte mso 9]><xml><o:shapelayout v:ext="edit"><o:idmap v:ext="edit" data="1"/></o:shapelayout></xml><![endif]--></head><body onload="initialize();checkFontSize();checkDocSize();" bgcolor="#000033" lang=DA style='tab-interval:65.2pt'><div class="indhold" id="broedtekst"><div class=Section1><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'>Test skabelon<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'><o:p> </o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'>sdfdsfsdfffffffff<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'>sdfdsfsdfffffffff<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'>sdfdsfsdfffffffff<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'>sdfdsfsdfffffffff<o:p></o:p></span></b></p><p class=MsoNormal><b style='mso-bidi-font-weight:normal'><spanstyle='font-size:24.0pt;font-family:Arial;color:white'>sdfdsfsdfffffffff<o:p></o:p></span></b></p>
</div>
</div>
</body>
</html>
