| 
      
       |  |  
       | 
  
  
   | 
     
      | 
 
  |  |  
  | Latest News | Latest Threads |  
  |  | 
    
     |  |  
     | 57.158 Posts & 4.945 Themen in 78 Foren |  |  |  
  |  |  
 
 
  
   | 
     
      |  | Forensuche |  |  Suchbegriff | Benutzerauswahl | Ergebnisse anzeigen |  
 
 
  |  |  
  | 
    
     |  | Javascript bei BBCodes 1 Beitrag in diesem Thema
 |  |  |  
 
  |  |  
  |  |  |  
 
  |  |  
  | 
    
     |  | 
       
        | 
          
           |  | 08.07.2009 - 19:41 Uhr |  |  
           |  |  |  
        | 
          
           | Guten Tag! 
 Mir ging die Sicherheitsmeldung des IE auf die Nerven, wenn man per BBCode einen Link einfügen oder ne EMail Addi angeben will.
 
 Also hab ich was zusammengebastelt was auch so weit funktioniert, bis auf eine Sache
  
 Die Übernahme von selektiertem Text, z.B. Linkname funktioniert nicht.
 Aufgerufen wird die Funktion showPrompt() im Template format_text.
 
 Die main.js :
 
 
  Hier klicken zum aufklappen    |          |                | 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
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 
 |  | Quellcode        ie5=(document.getElementById&&document.all&&document.styleSheets)?1:0;
 nn6=(document.getElementById&&!document.all)?1:0;
 promptWidth=330;
 promptHeight=200;
 
 // *** Text bei der Eingabeaufforderung ***********
 linkname = "Geben Sie bitte den Linknamen an (optional).";
 linkadresse = "Geben Sie bitte die vollständige Adresse des Links an.";
 emailname = "Geben Sie bitte die E-Mail-Adresse ein.";
 listentyp = "Für eine numerierte Liste geben Sie eine '1' an. Für eine alphabetische ein 'a'.\nFür eine einfache Punktliste drücken Sie ok.";
 listenwerte = "Geben Sie bitte die Listenpunkte ein und drücken Sie anschliessend ok.\nAlternativ können Sie 'Abbrechen' wählen, um die Liste direkt fertigzustellen.";
 promptTitle="<p align='center'><b>Eingabeaufforderung</b></p>";
 
 //**** Pop-Fenster **********
 function helpwindow(w,h,e) {
 window.open("include.php?path=popup&mode=help&explain="+e,"helpwindow","toolbar=no,scrollbars=yes,resizable=yes,status=no,width="+w+",height="+h);
 }
 function smiliewindow(w,h) {
 window.open("include.php?path=popup&mode=smilies&window_w_size="+w+"&window_h_size="+h,"smilies","toolbar=no,scrollbars=yes,resizable=yes,status=no,width="+w+",height="+h);
 }
 function finduserID(w,h) {
 window.open("include.php?path=popup&mode=finduser&window_w_size="+w+"&window_h_size="+h,"finduser","toolbar=no,scrollbars=yes,resizable=yes,status=no,width="+w+",height="+h);
 }
 function checkall(status,theelement) {
 for (i=0;i<document.myform.length;i++) {if(document.myform.elements[i].name=="" + theelement + "[]") document.myform.elements[i].checked=status;}
 }
 
 ondblclick="pkBBSelection(this);";
 
 /*bbcode*/
 var pkBBArea=null;
 var pkBBSelected='';
 
 function pkBBFocus()
 {
 pkBBArea.focus();
 }
 
 /*textselection*/
 function pkBBSelection(obj)
 {
 pkBBArea=obj;
 
 if(window.getSelection)
 pkBBSelected=pkBBArea.value.substring(pkBBArea.selectionStart,pkBBArea.selectionEnd);
 else if(document.getSelection)
 pkBBSelected=pkBBArea.value.substring(pkBBArea.selectionStart,pkBBArea.selectionEnd);
 else if(document.selection)
 pkBBSelected=document.selection.createRange().text;
 
 if(pkBBArea.createTextRange)
 pkBBArea.caretPos=document.selection.createRange().duplicate();
 
 return true;
 }
 
 function pkBBSingle(text)
 {
 text=' '+text+' ';
 pkBBCodeAdd(text);
 }
 
 function pkBBCodeAdd(text)
 {
 if(pkBBArea==null)
 {
 pkBBArea=document.getElementById('pkBBArea');
 pkBBFocus();
 pkBBSelection(pkBBArea);
 }
 
 if(window.getSelection)
 {
 pos=pkBBArea.selectionStart + text.length;
 pkBBArea.value=pkBBArea.value.substr(0,pkBBArea.selectionStart) + text + pkBBArea.value.substr(pkBBArea.selectionEnd);
 pkBBArea.selectionStart=pos;
 pkBBArea.selectionEnd=pos;
 }
 else if(pkBBArea.createTextRange && pkBBArea.caretPos)
 {
 var caretPos = pkBBArea.caretPos;
 caretPos.text = caretPos.text.charAt(caretPos.text.length - 1)==' ' ? text + ' ' : text;
 }
 else
 pkBBArea.value+=text
 
 pkBBFocus();
 }
 
 function pkBBCode(bbcode)
 {
 text=(pkBBSelected) ? pkBBSelected : '';
 text="["+bbcode+"]"+text+"[/"+bbcode+"]";
 
 pkBBCodeAdd(text);
 pkBBFocus();
 }
 
 /*link and email*/
 nameValue=(pkBBSelected) ? pkBBSelected : '';
 wertValue="http://";
 
 //okButton
 function okPrompt() {
 if( (document.promptform.wert.value != null) && (document.promptform.wert.value != "") && (document.promptform.wert.value != wertValue) ) {
 
 if((document.promptform.name.value != null) && (document.promptform.name.value != "")) {
 auswahltext = "+document.promptform.wert.value+"" class="hidelink" target="_blank">"+document.promptform.name.value+" ";
 pkBBCodeAdd(auswahltext);
 abortPrompt();
 }
 else {
 auswahltext = "+document.promptform.wert.value+"" class="hidelink" target="_blank">"+document.promptform.wert.value+" ";
 pkBBCodeAdd(auswahltext);
 abortPrompt();
 }
 }
 }
 
 //Abbruch
 function abortPrompt() {
 document.getElementById("prompt").style.top=-500;
 document.promptform.name.value="";
 document.promptform.wert.value=wertValue;
 }
 
 //Fenster generieren
 if(ie5||nn6) {
 if(ie5) cs=2,th=30;
 else cs=0,th=20;
 
 document.write(
 "<div style='position:absolute;top:-500;left:0;z-index:100' id='prompt'>"+
 "<table style='border-style
  utset;border-width:2;border-color:#E6E6CD;background-color:#F5F5DC' cellpadding='5' cellspacing='"+cs+"' width='"+promptWidth+"' height='"+promptHeight+"'>"+ "<tr><td height='"+th+"' bgcolor='#DEDEC5' align='center'>"+promptTitle+"</td></tr>"+
 "<form name='promptform' onsubmit='okPrompt();return false'>"+
 "<tr><td align='center'><br>"+linkname+"<br><input type='text' size='35' value='"+nameValue+"' name='name'></td></tr>"+
 "<tr><td align='center'><br>"+linkadresse+"<br><input type='text' size='35' value='"+wertValue+"' name='wert'></td></tr>"+
 "<tr align='center'><td><br><input type='button' value='    OK    ' onclick='okPrompt()' onfocus='if(this.blur)this.blur()'>"+
 "  "+
 "<input type='button' value='Abbrechen' onclick='abortPrompt()' onfocus='if(this.blur)this.blur()'>"+
 "</form></td></tr></table></div>"
 );
 }
 
 xPromptStart=100
 yPromptStart=100;
 
 function showPrompt() {
 if(ie5||nn6) {
 moveStatus=0;
 xPrompt=xPromptStart, yPrompt=yPromptStart;
 if(ie5) {
 document.getElementById("prompt").style.left=xPrompt+document.body.scrollLeft;
 document.getElementById("prompt").style.top=yPrompt+document.body.scrollTop;
 }
 else if(nn6) {
 document.getElementById("prompt").style.left=xPrompt+window.pageXOffset;
 document.getElementById("prompt").style.top=yPrompt+window.pageYOffset;
 }
 document.promptform.focus();
 }
 }
 
 
 
 //Original
 function pkBBLink(bbcode)
 {
 text=(pkBBSelected) ? pkBBSelected : '';
 
 linktext = prompt(linkname,text);
 
 var fensterausgabe;
 if (bbcode == "URL") {
 ausgabe = linkadresse;
 ausgabeinhalt = "http://";
 }
 else {
 ausgabe = emailname;
 ausgabeinhalt = "";
 }
 
 linkurl = prompt(ausgabe,ausgabeinhalt);
 
 if ((linkurl != null) && (linkurl != "")) {
 if ((linktext != null) && (linktext != "")) {
 auswahltext = "["+bbcode+"="+linkurl+"]"+linktext+"[/"+bbcode+"] ";
 pkBBCodeAdd(auswahltext);
 
 }
 else{
 auswahltext = "["+bbcode+"]"+linkurl+"[/"+bbcode+"] ";
 pkBBCodeAdd(auswahltext);
 }
 }
 }
 
 /* list */
 function pkBBList()
 {
 listtype=prompt(listentyp,'');
 
 if((listtype == "a") || (listtype == "1"))
 {
 mylist = "[list="+listtype+"]\n";
 listend = "[/list="+listtype+"] ";
 }
 else
 {
 mylist = "<ul>\n";
 listend = "</ul> ";
 }
 
 listentry="initial";
 while((listentry!="") && (listentry != null))
 {
 listentry=prompt(listenwerte,'');
 
 if((listentry!='') && (listentry != null))
 mylist = mylist+"[li]"+listentry+"[/li]\n";
 }
 
 pkBBCodeAdd(mylist+listend);
 }
 
 |  |     |  | 
 Kann mir da einer helfen?
 
 
 
 
  |  |  
  | Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von k!r!ka - 08.07.2009 - 20:14 Uhr |  |  
           |  |  
           |  |  |  |  |  |  
 
  |  |  
  |  |  |  
 
 
  | 
    
     |  | Ähnliche Themen |  
     |  |  |  |  
      | 
 |  |  |  
       |  |  |