Dynamisch erzeugte Divs sorgen für den Fehler "unterminated String lateral"
Moritz Mann
- javascript
Hallo jede Hilfe ist mir willkommen.
Ich arbeite gerade an ein paar jsp seiten. inden jeweiligen hauptteil include ich andere jsp seiten die jeweils den top sidemenu usw. erzeugen. in dem topteil habe ich eine sich an die client resolution anpassende javascript funktion, die immer die dynamisch erzeugten divs resizt.
jetzt kommt mein problem: hat mein seitliches menu ein paar submenupunkte (alles divs) wird der dynamisch per document.writeln() geschriebene code zerissen und ns meckert über unterminated string laterals, obwohl laut source code alles in ordnung ist. lasse ich das menu aussen vor ist alles in butter.
hier nocheinmal der javascriptcode:
<script>
function GenerateTop()
{
Awinwidth=0;
if (ns) {Awinwidth=window.innerWidth;Awinheight=window.innerHeight;}
if (ie) {Awinwidth= document.body.clientWidth;Awinheight= document.body.clientHeight;}
mcleft=Awinwidth-210;
topmenubarr=Awinwidth-121;
labelleft=Awinwidth-200;
labeltextleft=labelleft+50;
copyheight=Awinheight-45;
style01='<style>#headbar{position:absolute;height:36;top:0;left:0;width:'+Awinwidth+'px;clip:rect(0px,'+Awinwidth+'px,36px,0px);z-index:0}</style>';
style02='<style>.headbar{layer-background-color:#152037;background-color:#152037;}</style>';
style03='<style>#line{position:absolute;height:1;width:'+Awinwidth+'px;top:35;left:0;clip:rect(0px,'+Awinwidth+'px,1px,0px);z-index:1}</style>';
style04='<style>.line{layer-background-color:#aebed0;background-color:#aebed0;}</style>';
style05='<style>#headbar2{position:absolute;height:40;top:36;left:0;width:'+Awinwidth+'px;clip:rect(0px,'+Awinwidth+'px,40px,0px);z-index:0}</style>';
style06='<style>.headbar2{layer-background-color:#165088;background-color:#165088;}</style>';
style07='<style>#missionctrl{position:absolute;left:'+mcleft+';top:0}</style>';
style08='<style>#namefield{position:absolute;left:'+mcleft+'px;height:15px;top:39px;width:210px;clip:rect(0px,210px,15px,0px);z-index:15;}</style>';
style09='<style>.namefield{background-color:#5c9bcd;layer-background-color:#5c9bcd;}</style>';
style10='<style>#namefield2{position:absolute;left:'+mcleft+'px;height:15px;top:57px;width:210px;clip:rect(0px,210px,15px,0px);z-index:15;}</style>';
style11='<style>.namefield2{background-color:#5c9bcd;layer-background-color:#5c9bcd;}</style>';
style12='<style>#label1text{position:absolute;left:'+labeltextleft+'px;top:39px;z-index:15;}</style>';
style13='<style>#label2text{position:absolute;left:'+labeltextleft+'px;top:57px;z-index:15;}</style>';
style14='<style>#copyDiv{background-color:#152037;layer-background-color:#152037;position:absolute;left:0px;top:'+copyheight+'px;width:120px;}</style>';
style15='<style>#topmenubar1{width:'+topmenubarr+'px;clip:rect(0px,'+topmenubarr+'px,21px,0px);position:absolute;top:76px;left:121px;height:21px;z-index:-15;}</style>';
style16='<style>.topmenubar1{background-color:#0b78ca;layer-background-color:#0b78ca;}</style>';
document.write(style01);
document.write(style02);
document.write(style03);
document.write(style04);
document.write(style05);
document.write(style06);
document.write(style07);
document.write(style08);
document.write(style09);
document.write(style10);
document.write(style11);
document.write(style12);
document.write(style13);
document.write(style14);
document.write(style15);
document.write(style16);
document.close();
}
mache ich irgendwas falsch? wenn ja liegt das an den zu vielen divs?
Im vorraus danke für jede hilfe.
moritz
hi moritz
ich hatte ein ähnliches problem mit jsp, die lösung war: der server hat beim
erstaufruf an jede src und jedes href eine sessionID angehängt: statt <img src="bild.gif" .....
steht dann <img src="bild.gif?GXHC_gx_session_id_=b28e3fcc08a6c6ac">
bei divs, bildern etc die mit document.write geschrieben werden, kann das
zu problemen führen:
1. in <a href="javascript:befehl()?GXHC_gx_session_id_=b28e3fcc08a6c6ac">
--> Lösung: häng an den befehl // an, dann gilt die sessionID als Kommentar
--> oder maskiere href mit ...h"+"ref..., dann erkennts der server nicht mehr
--> gleiches mit src
natürlich muss man sich dann überlegen, wie die seite trotzdem die ID weitergeben kann
lg Hobbes