Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Tab in teaxarea issue

 
Post new topic   Reply to topic Printable version
 View previous topic  grabbing text Post :: Post % sings while obtaining information  View next topic  
Author Message
BugZap
Guest


Offline

PostPosted: Wed Jan 24, 2007 3:33 pm    Post subject: Tab in teaxarea issue Reply to topic Reply with quote

Seen the Tab in teaxarea issue of this fourm some where, heres a better fix.
It works with Firefox aswell as IE and wont cause error with unsupported browsers.
Also it inserts the tab in opera v? not sure v7+ maybe, however it will lose focus.


Code: Show/Hide

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
   <title>Tab-Fix</title>
</head>

<body>


<script type="text/javascript">
<!--

/**
* Insert a tab at the current text position in a textarea
* Jan Dittmer, jdittmer@ppp0.net, 2005-05-28
* Inspired by http://www.forum4designers.com/archive22-2004-9-127735.html
* Tested on:
*   Mozilla Firefox 1.0.3 (Linux)
*   Mozilla 1.7.8 (Linux)
*   Epiphany 1.4.8 (Linux)
*   Internet Explorer 6.0 (Linux)
* Does not work in:
*   Konqueror (no tab inserted, but focus stays)
*/
function insertTab(event,obj) {
    var tabKeyCode = 9;
    if (event.which) // mozilla
        var keycode = event.which;
    else // ie
        var keycode = event.keyCode;
    if (keycode == tabKeyCode) {
        if (event.type == "keydown") {
            if (obj.setSelectionRange) {
                // mozilla
                var s = obj.selectionStart;
                var e = obj.selectionEnd;
                obj.value = obj.value.substring(0, s) +
                    "\t" + obj.value.substr(e);
                obj.setSelectionRange(s + 1, s + 1);
                obj.focus();
            } else if (obj.createTextRange) {
                // ie
                document.selection.createRange().text="\t"
                obj.onblur = function() { this.focus(); this.onblur = null; };
            } else {
                // unsupported browsers
            }
        }
        if (event.returnValue) // ie ?
            event.returnValue = false;
        if (event.preventDefault) // dom
            event.preventDefault();
        return false; // should work in all browsers
    }
    return true;
}

//-->
</script>
<input type="text">
<br>
<textarea onkeydown="return insertTab(event,this);"
      onkeyup="return insertTab(event,this);"
      onkeypress="return insertTab(event,this);"
      rows="30" cols="80">
</textarea>
<br>
<input type="text">
</body>
</html>

Back to top
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:36
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3607
Location: Las Vegas
Offline

PostPosted: Wed Jan 24, 2007 4:09 pm    Post subject: Reply to topic Reply with quote

Thank you, works better.
Back to top
View users profile Send private message Add User to Ignore List Send email
Maverick
broken record


Age:35
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Wed Jan 24, 2007 5:22 pm    Post subject: Reply to topic Reply with quote

That's actually pretty nice. It's always annoying to code in a textfield because of that.
MGB, can you also apply it to the fast reply? icon_smile.gif
_________________
Nickname: Maverick (I changed my name!)
TWCore developer | Subspace statistics
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:36
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3607
Location: Las Vegas
Offline

PostPosted: Wed Jan 24, 2007 6:08 pm    Post subject: Reply to topic Reply with quote

Maverick wrote:
MGB, can you also apply it to the fast reply? :)

I never use it, but added it to the Quick Reply.
Back to top
View users profile Send private message Add User to Ignore List Send email
Maverick
broken record


Age:35
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Thu Jan 25, 2007 2:41 am    Post subject: Reply to topic Reply with quote

Code: Show/Hide
            nice, thanks :)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bugguy
Guest


Offline

PostPosted: Thu Jan 25, 2007 4:07 am    Post subject: Reply to topic Reply with quote

holy chit,, it works icon_exclaim.gif
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 112 page(s) served in previous 5 minutes.

phpBB Created this page in 0.118557 seconds : 30 queries executed (34.9%): GZIP compression disabled