Neue absatz wird nicht generiert
PM
- javascript
Hallo zusammen,
folg Problem bitte: ich wollte ein dynamic text haben und hab hier den passende script gefunden: http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm
Alles schon und gut, funkt auch bis auf den prolem absatz; bilder und texte kommen alle (wenn nicht geoffnet) neben ein andere sozusagen stufenweise.
Anbei der Hinhalt: wo ist bitte den Fehler ?
</script>
<style type="text/css">
/*Style sheet used for demo. Remove if desired*/
.handcursor{
cursor:hand;
}
</style>
<title></title>
<meta name="author" content="">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000CC" alink="#0000CC" vlink="#0000CC">
<div><h5><a style="text-decoration:none" href="javascript:bobexample.sweepToggle('contract')">Contract</a> | <a style="text-decoration:none" href="javascript:bobexample.sweepToggle('expand')">Expand</a></div></h5>
<h3 id="bobcontent1-title" class="handcursor"><img src="../img/Kopie von stockxpertcom_id476617_size1.jpg" width="120" height="100"align="left" vspace="1" hspace="5">Projekt <b>„XXXXXX“</b> bei XXXXX </h3>
<div id="bobcontent1" class="switchgroup1">
bla bla bla blabla
</div>
<h3 id="bobcontent2-title" class="handcursor"><img src="../img/stockxpertcom_id820002_size1.jpg" width="130" height="80"align="left" vspace="1" hspace="5">Projekt <b>„XXX“</b> XXXX </h3>
<div id="bobcontent2" class="switchgroup1">
bla bla bla blabla
</div>
<h3 id="bobcontent3-title" class="handcursor"><img src="../img/fotolia_4650402.jpg" width="90" height="120"align="left" vspace="1" hspace="5">Projekt <b>"xxx"</b> XXXXXXX <p></h3>
<div id="bobcontent3" class="switchgroup1">
bla bla bla blabla
</div>
<script type="text/javascript">
// MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
//1) Instance.setStatus(openHTML, closedHTML)- Sets optional HTML to prefix the headers to indicate open/closed states
//2) Instance.setColor(openheaderColor, closedheaderColor)- Sets optional color of header when it's open/closed
//3) Instance.setPersist(true/false)- Enables or disabled session only persistence (recall contents' expand/contract states)
//4) Instance.collapsePrevious(true/false)- Sets whether previous content should be contracted when current one is expanded
//5) Instance.defaultExpanded(indices)- Sets contents that should be expanded by default (ie: 0, 1). Persistence feature overrides this setting!
//6) Instance.init() REQUIRED
var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
bobexample.setColor('darkred', 'black')
bobexample.setPersist(true)
bobexample.collapsePrevious(true) //Only one content open at any given time
bobexample.init()
</script>
<script type="text/javascript">
var joeexample=new switchcontent("switchgroup2", "p") //Limit scanning of switch contents to just "p" elements
joeexample.setStatus('[open] ', '[closed] ')
joeexample.setColor('green', 'red')
joeexample.collapsePrevious(false) //Allow more than 1 content to be open simultanously
joeexample.setPersist(false)
joeexample.defaultExpanded(0,1)
joeexample.init()
</script>
</body>
</html>
Hallo,
Anbei der Inhalt: wo ist bitte den Fehler ?
Ziemliches Chaos. Dein HTML ist jedenfalls ungültig, z.B. fehlt den <img ...>-tags immer die schließende Klammer ">".
Gruß, Don P
Hallo Don,
da sind doch klammern da; hier der befehl noch:
<img src="../img/Kopie von stockxpertcom_id476617_size1.jpg" width="120" height="100"align="left" vspace="1" hspace="5">
das hier ist der original script....der ist doch mit meine identisch (ist ya der gleiche). Grund mehr dass ich den prob nicht verstehe.
<h2>Demo 1</h2>
<div><a href="javascript:bobexample.sweepToggle('contract')">Contract All</a> | <a href="javascript:bobexample.sweepToggle('expand')">Expand All</a></div>
<h3 id="bobcontent1-title" class="handcursor">What is JavaScript?</h3>
<div id="bobcontent1" class="switchgroup1">
JavaScript is a scripting language originally developed by Netscape to add interactivity
and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
</div>
<h3 id="bobcontent2-title" class="handcursor">Difference betwen Java & JavaScript?</h3>
<div id="bobcontent2" class="switchgroup1">
Java is completely different from JavaScript.
The former is a compiled language while the later is a scripting language.
</div>
<h3 id="bobcontent3-title" class="handcursor">What is DHTML?</h3>
<div id="bobcontent3" class="switchgroup1">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML.
Through them a new level of interactivity is possible for the end user experience.
</div>
<script type="text/javascript">
// MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
//1) Instance.setStatus(openHTML, closedHTML)- Sets optional HTML to prefix the headers to indicate open/closed states
//2) Instance.setColor(openheaderColor, closedheaderColor)- Sets optional color of header when it's open/closed
//3) Instance.setPersist(true/false)- Enables or disabled session only persistence (recall contents' expand/contract states)
//4) Instance.collapsePrevious(true/false)- Sets whether previous content should be contracted when current one is expanded
//5) Instance.defaultExpanded(indices)- Sets contents that should be expanded by default (ie: 0, 1). Persistence feature overrides this setting!
//6) Instance.init() REQUIRED
var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
bobexample.setStatus('<img src="http://img242.imageshack.us/img242/5553/opencq8.png" /> ', '<img src="http://img167.imageshack.us/img167/7718/closedy2.png" /> ')
bobexample.setColor('darkred', 'black')
bobexample.setPersist(true)
bobexample.collapsePrevious(true) //Only one content open at any given time
bobexample.init()
</script>
<h2>Demo 2</h2>
<h3 id="joecontent1-title" class="handcursor">What is JavaScript?</h3>
<p id="joecontent1" class="switchgroup2">
JavaScript is a scripting language originally developed by Netscape to add interactivity and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
</p>
<h3 id="joecontent2-title" class="handcursor">Difference betwen Java & JavaScript?</h3>
<p id="joecontent2" class="switchgroup2">
Java is completely different from JavaScript- the former is a compiled language while the later is a scripting language.
</p>
<h3 id="joecontent3-title" class="handcursor">What is DHTML?</h3>
<p id="joecontent3" class="switchgroup2">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML. Through them a new level of interactivity is possible for the end user experience.
</p>
<script type="text/javascript">
var joeexample=new switchcontent("switchgroup2", "p") //Limit scanning of switch contents to just "p" elements
joeexample.setStatus('[open] ', '[closed] ')
joeexample.setColor('green', 'red')
joeexample.collapsePrevious(false) //Allow more than 1 content to be open simultanously
joeexample.setPersist(false)
joeexample.defaultExpanded(0,1)
joeexample.init()
</script>
Hallo,
das hier ist der original script....der ist doch mit meine identisch (ist ya der gleiche).
Nein, ist es nicht. Im original Script steht z.B. nicht so eine falsche HTML-Struktur, wie bei dir:
<h3 id="bobcontent3-title" class="handcursor"> [...] <p></h3>
^^^Fehler!
Ein <p>-Element kann nicht innerhalb eines <h3> beginnen, und es gibt auch kein Ende </p>.
Grund mehr dass ich den prob nicht verstehe.
Es gibt im original-Code zwei Beispiele, "Demo 1" mit <div>-Elementen und "Demo 2" mit <p>-Elementen
Dein Code führt nacheinender die Javascript-Befehle für beide Beispiele aus, aber es existiert nur das HTML von "Demo 1" (<div>-Elemente), mit einem einzigen falsch platzierten <p>-Starttag.
Die Script-Befehle für <p>-Elemente können also gar nicht funktionieren, weil dein HTML keine <p>-Elemente enthält.
Gruß, Don P
Hallo,
Nein, sorry die Klammern sind ja da. Du solltest alles besser strukturieren, damit es leserlich wird.
Javascript-Befehle sollten immer mit Semikolon ";" abgeschlossen werden.
Gruß, Don P