1. Liebe Forumsgemeinde,

    aufgrund der Bestimmungen, die sich aus der DSGVO ergeben, müssten umfangreiche Anpassungen am Forum vorgenommen werden, die sich für uns nicht wirtschaftlich abbilden lassen. Daher haben wir uns entschlossen, das Forum in seiner aktuellen Form zu archivieren und online bereit zu stellen, jedoch keine Neuanmeldungen oder neuen Kommentare mehr zuzulassen. So ist sichergestellt, dass das gesammelte Wissen nicht verloren geht, und wir die Seite dennoch DSGVO-konform zur Verfügung stellen können.
    Dies wird in den nächsten Tagen umgesetzt.

    Ich danke allen, die sich in den letzten Jahren für Hilfesuchende und auch für das Forum selbst engagiert haben. Ich bin weiterhin für euch erreichbar unter tti(bei)pcwelt.de.
    Dismiss Notice

Problem mit Formular und Javascript

Discussion in 'Programmieren' started by mannyk, Sep 16, 2004.

Thread Status:
Not open for further replies.
  1. mannyk

    mannyk Halbes Megabyte

    Hi!
    Ich habe ein formularfeld mit dem ich per Mausklick Smileys und den Text formatieren kann. Das funktionier alles auch super.
    Wenn ich aber per "Zurück-Taste" mit dem Browser wieder auf diese Seite gehe, kommt die Fehlermeldung: "document.replier.Font_Type ist Null oder kein Objekt".

    Hier poste ich mal den Javascript - Code:
    Code:
    <script language="Javascript" type="text/javascript">
    <!--
    function restore()
      {
        document.replier.Font_Type.value="00";
        document.replier.Font_Size.value="00";
        document.replier.Font_Color.value="00";
        document.replier.Font_Glow_Color.value="00";
        document.replier.Font_Back_Color.value="00";
        document.replier.Font_Style.value="00";
        document.replier.Special_Option.value="00";
        document.replier.Web_Option.value="00";
        document.replier.Code.value="00";
        document.replier.HTML_Option.value="00";
        document.replier.List_Poll.value="00";
        document.replier.Move_Text.value="00";
        return;
      }
    //-->
    </script>
                        <script language="JavaScript" type="text/javascript">
    <!--
    function x () {
    return;
    }
    function storeCaret (textEl) {
    	if (textEl.createTextRange)
    		textEl.caretPos = document.selection.createRange().duplicate();
    } // end fn
    
    function insertAtCaret (textEl, text) {
    	if (textEl.createTextRange && textEl.caretPos) {
    		var caretPos = textEl.caretPos;
    		caretPos.text =
    			caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
    			text + ' ' : text;
    	} else {
    		textEl.value  = textEl.value + text; // for non MSIE browsers just append it
    	}
    	restore();
    	return true;
    }// fn
    
    
    
    
    function DoSmilie(addSmilie) {
    	 var revisedMessage;
    	 var currentMessage = document.replier.Body.value;
    	 revisedMessage = currentMessage+addSmilie;
    	 document.replier.Body.value=revisedMessage;
    	 document.replier.Body.focus();
    	 restore();
    	 return;
    }
    function FontType(font) {
    	 var this_FontType_1 = prompt("Gewählte oder andere ''Schriftart'' eingeben.", "" +font + "");
    	 if (this_FontType_1 == null){return;}
    
    	 var this_FontType_2 = prompt("Bitte gebe deinen Text ein !", "Dein Text");
    	 if (this_FontType_2 == null){return;}
    
    	 insertAtCaret(document.replier.Body, '' + "[Schriftart=" + this_FontType_1 + "]" + this_FontType_2 + "[/Schriftart]" + '');
    	 document.replier.Body.focus();
         restore();
    	 return;
    }
    function FontSize(size) {
    	 var this_FontSize_1 = prompt("Bitte gewünschte Schrift Größe von ''1 - 7'' eingeben.", "" +size + "");
    	 if (this_FontSize_1 == null){return;}
    
    	 var this_FontSize_2 = prompt("Bitte gebe deinen Text ein !", "Dein Text");
    	 if (this_FontSize_2 == null){return;}
    
    	 insertAtCaret(document.replier.Body, '' + "[Groesse=" + this_FontSize_1 + "]" + this_FontSize_2 + "[/Groesse]" + '');
    	 document.replier.Body.focus();
             restore();
    	 return;
    }
    function FontColor(color) {
    	 var this_FontColor_1 = prompt("Gewählten oder anderen ''Farb Code'' eingeben. (ohne #)", "" +color + "");
    	 if (this_FontColor_1 == null){return;}
    
    	 var this_FontColor_2 = prompt("Bitte gebe deinen Text ein !", "Dein Text");
    	 if (this_FontColor_2 == null){return;}
    
    	 insertAtCaret(document.replier.Body, '' + "[Farbe=#" + this_FontColor_1 + "]" + this_FontColor_2 + "[/Farbe]" + '');
    	 document.replier.Body.focus();
             restore();
    	 return;
    }
    function DoPrompt(action) {
    	 var currentMessage = document.replier.Body.value;
    if (action == "color") {
        var this_Color = prompt("Gib eine beliebige Farbe an, die Du verwenden möchtest. Der Farbcode sollte wie folgt aussehen: #ff1123 oder 'blue','red','green', etc.","Text");
        if (this_Color == null) {return; }
        insertAtCaret(document.replier.Body, '' + "[Farbe:" + this_Color + "] [/Farbe] ");
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Url") {
        var this_Url = prompt("Bitte die komplette ''Url'' eingeben.", "http://www.");
        if (this_Url == null){return;}
    
        var this_Title = prompt("Name der Netzseite", "Netzseite");
        if (this_Title == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Adresse=" + this_Url + "]" + this_Title + "[/Adresse]" + '');
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Email") {
        var this_Email = prompt("Bitte die komplette ''E-Post Adresse'' eingeben.", "deine\@e-post.at");
        if (this_Email == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Epost]" + this_Email + "[/Epost]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Image") {
        var this_Image = prompt("Bitte die komplette ''Url des Bildes'' eingeben.", "http://");
        if (this_Image == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Bild]" + this_Image + "[/Bild]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Bold") {
        var this_Bold = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Bold == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[b]" + this_Bold + "[/b]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Italics") {
        var this_Italics = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Italics == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[i]" + this_Italics + "[/i]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Underline") {
        var this_u = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_u == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[u]" + this_u + "[/u]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Strike") {
        var this_s = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_s == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[s]" + this_s + "[/s]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Sup") {
        var this_sup = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_sup == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[sup]" + this_sup + "[/sup]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Sub") {
        var this_sub = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_sub == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[sub]" + this_sub + "[/sub]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "hr") {
        insertAtCaret(document.replier.Body, '' + "[hr]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }	
    if (action == "*") {
        insertAtCaret(document.replier.Body, '' + "[*]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Left") {
        var this_Left = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Left == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Links]" + this_Left + "[/Links]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }	
    if (action == "Right") {
        var this_Right = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Right == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Rechts]" + this_Right + "[/Rechts]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }	
    if (action == "Center") {
        var this_Center = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Center == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Mitte]" + this_Center + "[/Mitte]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }		
    if (action == "Justify") {
        var thisJustify = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (thisJustify == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Blocksatz]" + thisJustify + "[/Blocksatz]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }
    if (action == "Quote") {
        var this_Quote = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Quote == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[Zitat]\n" + this_Quote + "\n[/Zitat]" + '' );
        document.replier.Body.focus();
        restore();
        return;
    }		
    if (action == "Code") {
        var this_Code = prompt("Bitte gebe deinen Text ein !", "Dein Text");
        if (this_Code == null){return;}
    
        insertAtCaret(document.replier.Body, '' + "[code]\n" + this_Code + " \n
    " + '\n' );
    document.replier.Body.focus();
    restore();
    return;
    }
    // -->
    }
    //-->
    restore();
    </script>

    [/CODE]
     
Thread Status:
Not open for further replies.

Share This Page