Skip to content

Instantly share code, notes, and snippets.

Nanshi xu33

Block or report user

Report or block xu33

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
xu33 / html encode and decode
Created Sep 18, 2013
html encode and decode
View html encode and decode
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
function htmlUnescape(value){
xu33 / read image from upload
Created Sep 4, 2013
read image from upload
View read image from upload
function view() {
var f = document.getElementById("file").files[0];
var reader = new FileReader();
reader.onload = (function(evt) { //evt get all value
document.getElementById('div').innerHTML =
"PIC :<img src=" + + "/>" ;
xu33 / new_gist_file
Created Aug 29, 2013
Set Cursor Position in Text Area
View new_gist_file
function setSelectionRange(input, selectionStart, selectionEnd) {
if (input.setSelectionRange) {
input.setSelectionRange(selectionStart, selectionEnd);
else if (input.createTextRange) {
var range = input.createTextRange();
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
You can’t perform that action at this time.