You are not logged in.

  • Login

Dear visitor, welcome to Coder Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, January 8th 2007, 10:40pm

Box öffnet sich beim 2ten Reload der Seite

Hallo,
da ich von einem Bekannten ein Javascript bekommen habe was ich gut gebrauchen könnte und er im Urlaub ist, frage ich euch mal ob mir jemand weiter helfen kann ?

Das Script öffnen und schlißt eine Box im Table Tag, mit eine Button für + und oder - zum schließen. Das ist auch soweit ok, nur wenn ich auf der HP irgendwelche etwas rumklicke öffnet sich die Box in unregelmäßigen Abständen was diese aber nciht machen soll. Die Box solle nur bei klick auf sein und solange offen bleiben bis man auf zu klickt. Bei ersten aufruf der HP soll die Box geschloßen bleiben bis man auf Box öffnen klickt.

Das Javascript

JavaScript Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<script type="text/javascript">
 
var enablepersist="on" 
var memoryduration="7"
 
var contractsymbol='minus.gif'
var expandsymbol='plus.gif'
 
 
function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}
 
function sweeptoggle(ec){
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=(ec=="contract")? "none" : ""
inc++
}
revivestatus()
}
 
 
function expandcontent(curobj, cid){
if (ccollect.length>0){
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="none")? "none" : ""
curobj.src=(document.getElementById(cid).style.display=="none")? expandsymbol : contractsymbol
}
}
 
function revivecontent(){
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="none"
}
 
function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="none")
statecollect[inc].src=expandsymbol
else
statecollect[inc].src=contractsymbol
inc++
}
}
 
function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
 
function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}
 
function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="none")
selectedItem+=ccollect[inc].id+"|"
inc++
}
if (get_cookie(window.location.pathname)!=selectedItem){ 
var expireDate = new Date()
expireDate.setDate(expireDate.getDate()+parseInt(memoryduration))
document.cookie = window.location.pathname+"="+selectedItem+";path=/;expires=" + expireDate.toGMTString()
}
}
 
function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
revivecontent()
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}
 
if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload
 
if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate
 
</script>

2

Monday, January 8th 2007, 11:02pm

Move

Das gehört nicht ins Java-Verzeichnis, sondern in den HTML-Folder...

Java != JavaScript :!:

3

Tuesday, January 9th 2007, 4:02pm

habs thema verschoben

@topic:

Quoted from ""markus""

...nur wenn ich auf der HP irgendwelche etwas rumklicke öffnet sich die Box in unregelmäßigen Abständen was diese aber nciht machen soll. Die Box solle nur bei klick auf sein und solange offen bleiben bis man auf zu klickt.


Was heißt denn irgendwo rumklicken? Bei einem Klick in den leeren Raum öffnet sich die Box? Poste mal den HTML Code dazu und validiere diesen am besten vorab bei http://validator.w3.org

4

Wednesday, January 10th 2007, 10:29pm

Danke, beimEinbau ist mir ein Fehler unterlaufen, jetzt klappt es aber.

Eine Frage habe ich noch, ich habe zb sowas für PopUp Fenster

JavaScript Code

1
2
3
4
5
6
function pop(file,windowname,features)
{
helpwindow = window.open(file,windowname,features);
helpwindow.focus();
return false;
}

kann man eigentlcih diesen Code in der selben xxx.js Datei packen wie der von oben oder muß man für jeden Code eine Extra Datei erstellen ?

5

Wednesday, January 10th 2007, 10:50pm

Kann in die gleiche Datei..

mfg
n3or

Social bookmarks