Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Mozilla/Firefox text scroll fix.

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Eric Coleman Posted - 15 December 2006 : 11:30:53
This really isn't a full mod, but I didn't know where else to post this.

The bug is when using the javascript formating options, such as bold, italics, etc, in a textbox with enough lines of text to have scroll bars, the textbox scrolls all the way to the top.

This easy fix keeps the scroll bar where it is when click the formating buttons.

Open inc_code.js and find the following function AddText

Code needs to be placed at the beginning of the function and at the end of the function:

Paste the following

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


at the top, immediatly after function AddText(text) {


Then, at the bottom of the function, paste the following:

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


immediately BEFORE the closing } of the function.


That's it.

If you haven't made any changes to your javascript then the default function, as being used by this forum right now, would look like this where new code is blue and old code is red.


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();
		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) {}; 
}

<
2   L A T E S T    R E P L I E S    (Newest First)
Shaggy Posted - 17 April 2008 : 12:11:19
Ah-ha! Knew I'd seen this somewhere

But, of course, the byte-scrimping coder in me had to clean it up a bit
function AddText(text) {
	var tarea = document.PostTopic.Message;
	if (typeof tarea.selectionStart != 'undefined'){ // if it supports DOM2
		start = tarea.selectionStart;
		end = tarea.selectionEnd;
		var posTop = tarea.scrollTop;
		var posLeft = tarea.scrollLeft;
		tarea.value = tarea.value.substr(0,tarea.selectionStart)
			+ text + tarea.value.substr(tarea.selectionEnd);
		tarea.focus();
		tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
		tarea.selectionEnd = start + text.length;
		tarea.scrollTop = posTop;
		tarea.scrollLeft = posLeft;
	} else if (tarea.createTextRange && tarea.caretPos) {
		var caretPos = tarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?   text + ' ' : text;
		tarea.focus(caretPos);
	} else {
		tarea.value += text;
	}
}
<
HuwR Posted - 15 December 2006 : 11:46:04
nice one, I guess it should be included in a future release at some point.<

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000 Version 3.4.07