/*Element auto scroller*/
function scroll_to_bottom(obj,speed){
//$('html, body').animate({scrollTop: $('html, body')[0].scrollHeight});
if(!obj){
obj = $('html, body');
}
if(!speed){
speed = '';
}
obj.animate({scrollTop: obj[0].scrollHeight},speed);
}
function scroll_to_top(obj,speed,top_margin){
//$('html, body').animate({scrollTop:0});
if(!obj){
obj = $('html, body');
}
if(!speed){
speed = '';
}
if(!top_margin){
top_margin = 0;
}
obj.animate({scrollTop:top_margin},speed);
}
usage
$(document).ready(function(){
var obj = $('.class_of_element');
Or
var obj = $('#id_of_element');
var speed = 2000; //in milliseconds ie 2 second
scroll_to_bottom(obj,speed)
});
/*get base url*/
var protocol = window.location.protocol;
var hostname = window.location.hostname;
var port = window.document.location.port;
var full_pathname = window.location.pathname;
var split_pathname = full_pathname.split( '/' );
var pathname = split_pathname[1];
/*Server path*/
//var base_url = protocol+"//"+hostname;
/*Server path*/
/*Local path*/
var base_url = protocol+"//"+hostname+"/"+pathname;
/*Local path*/
//Selected == selected if you know option value
var c_id = 3; //option value
$("#selectbox_id option").each(function(){
if($(this).val() == c_id){
$(this).attr("selected","selected");
return false;
}
});
OR
$('#selectbox_id>option:eq('+u_id+')').attr('selected', true);
/*Returns '-------' if variable passed is null, blank, or undefined.*/
function is_blank(val){
if(!val){
var str = '-------';
}
else{
var str = val;
}
return str;
}
/*Returns '-------' if variable passed is null, blank, or undefined.*/
//skip script tag in text area // js malware
function strip_script_tag_js(fieldStr){
//code to replace
var new_fieldStr=fieldStr.replace(/(\
No Comments