Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Cool help me test the code on the firefox, mozilla, netscape navigator, please

    Hello;
    i got a bbcode, and i want to it whether it can be compatibility with firefox, mozilla, netscape navigator, please, and i has not of them. Would anyone help me to test it, please. Just see it can work on them or not.


    test.html
    Code:
    <html>
    <head>
    
    <script language="Javascript">
    var isMozilla = (navigator.userAgent.toLowerCase().indexOf('gecko')!=-1) ? true : false;
    var regexp = new RegExp("[\r]","gi");
    
    function storeCaret(selec)
    {
    	if (isMozilla) 
    	{
    	// Si on est sur Mozilla
    
    		oField = document.forms['news'].elements['newst'];
    
    		objectValue = oField.value;
    
    		deb = oField.selectionStart;
    		fin = oField.selectionEnd;
    
    		objectValueDeb = objectValue.substring( 0 , oField.selectionStart );
    		objectValueFin = objectValue.substring( oField.selectionEnd , oField.textLength );
    		objectSelected = objectValue.substring( oField.selectionStart ,oField.selectionEnd );
    
    	//	alert("Debut:'"+objectValueDeb+"' ("+deb+")\nFin:'"+objectValueFin+"' ("+fin+")\n\nSelectionné:'"+objectSelected+"'("+(fin-deb)+")");
    			
    		oField.value = objectValueDeb + "[" + selec + "]" + objectSelected + "[/" + selec + "]" + objectValueFin;
    		oField.selectionStart = strlen(objectValueDeb);
    		oField.selectionEnd = strlen(objectValueDeb + "[" + selec + "]" + objectSelected + "[/" + selec + "]");
    		oField.focus();
    		oField.setSelectionRange(
    			objectValueDeb.length + selec.length + 2,
    			objectValueDeb.length + selec.length + 2);
    	}
    	else
    	{
    	// Si on est sur IE
    		
    		oField = document.forms['news'].elements['newst'];
    		var str = document.selection.createRange().text;
    
    		if (str.length>0)
    		{
    		// Si on a selectionné du texte
    			var sel = document.selection.createRange();
    			sel.text = "[" + selec + "]" + str + "[/" + selec + "]";
    			sel.collapse();
    			sel.select();
    		}
    		else
    		{
    			oField.focus(oField.caretPos);
    		//	alert(oField.caretPos+"\n"+oField.value.length+"\n")
    			oField.focus(oField.value.length);
    			oField.caretPos = document.selection.createRange().duplicate();
    			
    			var bidon = "%~%";
    			var orig = oField.value;
    			oField.caretPos.text = bidon;
    			var i = oField.value.search(bidon);
    			oField.value = orig.substr(0,i) + "[" + selec + "][/" + selec + "]" + orig.substr(i, oField.value.length);
    			var r = 0;
    			for(n = 0; n < i; n++)
    			{if(regexp.test(oField.value.substr(n,2)) == true){r++;}};
    			pos = i + 2 + selec.length - r;
    			//placer(document.forms['news'].elements['newst'], pos);
    			var r = oField.createTextRange();
    			r.moveStart('character', pos);
    			r.collapse();
    			r.select();
    
    		}
    	}
    }
    
    </script>
    </head>
    
    <body>
    <center>
    <form name="news">
    <input type="button" value="b" style="width:50px;font-weight:bold" onclick="storeCaret('b')">
    <input type="button" value="i" style="width:50px;font-style:italic" onclick="storeCaret('i')">
    <input type="button" value="u" style="width:50px;text-decoration:underline" onclick="storeCaret('u')">
    <input type="button" value="quote"style="width:50px" onclick="storeCaret('quote')">
    <input type="button" value="code"style="width:50px" onclick="storeCaret('code')">
    <input type="button" value="url"style="width:50px" onclick="storeCaret('url')">
    <input type="button" value="img"style="width:50px" onclick="storeCaret('img')"><br>
    <textarea name="newst" id="newst" rows="10" wrap="virtual" cols="45"></textarea>
    </form>
    </center>
    </body>
    
    </html>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    All of those browsers are available to download for free so what is stopping you?
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •