Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: General / Classic ASP versions(v3.4.XX)
 Post Editor Button JS Help
 New Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 December 2014 :  12:29:35  Show Profile  Visit bobby131313's Homepage  Reply with Quote
Can this be modified to put the cursor between the tags instead of after them? I'm very javascript challenged.


function bold() {
	var text = getText();
	if (helpstat) {
		alert("Bold Tag Makes the enclosed text bold.\n\nUSE: This is some bold text");
	} else if (basic) {
		AddTxt="" + text + "";
		AddText(AddTxt);
	} else {
		if (text) {
			txt=prompt("Text to be made BOLD.",text);
		} else {
			txt=prompt("Text to be made BOLD.","Text");
		}
		if (txt!=null) {
			AddTxt=""+txt+"";
			AddText(AddTxt);
		}
	}
}


Switch the order of your title tags

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 11 December 2014 :  13:04:18  Show Profile  Visit HuwR's Homepage
the function that positions the cursor is AddText, it should place the curcor between the tags.

Which browser and version etc are you using ?

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 11 December 2014 :  13:05:35  Show Profile  Visit HuwR's Homepage
mmm, seems it doesn't. I'm sure it used to

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 December 2014 :  13:39:39  Show Profile  Visit bobby131313's Homepage
Yeah, never has using any browser since I installed the forum almost 10 years ago.

I get asked about it all the time, mainly from mobile users, I've just never pursued it until now.

Switch the order of your title tags
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 December 2014 :  13:41:03  Show Profile  Visit bobby131313's Homepage
Seems that AddText function only works in Prompt mode?

Switch the order of your title tags
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 December 2014 :  14:18:58  Show Profile  Visit bobby131313's Homepage
I see what you're saying now, it's not the code I posted. Seems I replaced this once in 2008 by my notes for a "Firefox Jump" bug that I don't remember.

Switch the order of your title tags
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 December 2014 :  14:23:01  Show Profile  Visit bobby131313's Homepage
Here it is.....

http://forum.snitz.com/Forum/topic.asp?TOPIC_ID=63557

I'll play with it a bit.

Switch the order of your title tags
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 12 December 2014 :  21:13:57  Show Profile  Visit bobby131313's Homepage
Had some help, this works perfectly for me.... Your mileage may vary...


   function AddText(text) {

	var crtScrollTop;
	var crtScrollLeft;
	try {
		var tarea = document.PostTopic.Message;
		if (typeof tarea.scrollTop != 'undefined') {
			crtScrollTop = tarea.scrollTop;
			crtScrollLeft = tarea.scrollLeft;
		}
	} catch (e) {};

	var tarea = document.PostTopic.Message;
	if (typeof tarea.selectionStart != 'undefined')
	{ // if it supports DOM2
		start = tarea.selectionStart;
		end = tarea.selectionEnd;
		tarea.value = tarea.value.substr(0,tarea.selectionStart)
			+ text + tarea.value.substr(tarea.selectionEnd);
		tarea.focus();

		if (start === end )
		{
			res = text.split("/");
			if (res.length > 1)
			{
				tarea.selectionStart = start + (text.length) / 2;
				tarea.selectionEnd = tarea.selectionStart;
			}
			
		}
		else
		{
			tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
			tarea.selectionEnd = start + text.length;
		}
	} 
	else 
	{
		if (tarea.createTextRange && tarea.caretPos) {
			var caretPos = tarea.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?   text + ' ' : text;
		}
		else {
			tarea.value += text;
		}
		tarea.focus(caretPos);
	}

	try {
		var tarea = document.PostTopic.Message;
		if (typeof tarea.scrollTop != 'undefined') {
			tarea.scrollTop = crtScrollTop;
			tarea.scrollLeft = crtScrollLeft;
		}
	} catch (e) {}; 
}


Switch the order of your title tags
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 13 December 2014 :  09:21:45  Show Profile  Visit HuwR's Homepage
will try it here if I get chance later

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 13 December 2014 :  13:23:04  Show Profile  Visit bobby131313's Homepage
Cool, it has the "Jump" fix incorporated from 2008 also.

Ironically, back then it was FF doing it, now it's Chrome.

Switch the order of your title tags
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07