How to append html end of body tag

I created the following script putting the html at the end of body tag.
If you are using or following web 2.0(Table less HTML) standards for creating the HTMLs then this script will work 100%
Just Put this script in your HTML and see the html source. You will able to see the div id named “purab” with the test content.
<script type=’text/javascript’>
var purab = document.createElement(‘div’);
purab.id = ‘form_purab’;
var all_divs = document.getElementsByTagName(‘div’);
if (document.body.firstChild){
document.body.insertBefore(purab, all_divs[all_divs.length] );
} else {
document.body.appendChild(purab);
}
var oldHTML = document.getElementById(‘form_purab’).innerHTML;
var newHTML = “test content”;
//document.getElementById(‘form_purab’).innerHTML = newHTML;
var all_divs = document.getElementsByTagName(“div”);
//alert(all_links[all_links.length – 1].innerHTML);
all_divs[all_divs.length – 1].innerHTML = newHTML;
</script>

 

Have fun!

Advertisements

Finding mouse position browser and screen size javascript

Following script Will tested and working on following browsers.
1. Firefox 2+
2. Google chrome
3. Safari
4. IE 6, 7, 8
5. Opera
You can Use following code for Capturing the Mouse coordinates as per Document body
var isIE = document.all?true:false;
// document.onmousemove = getMousePosition;
// document.onmousemove = getscreenPosition;
function getMousePositionBrowsersizeWise(e) { // as per Document body
var _x;
var _y;
if (!isIE) {
_x = e.pageX;
_y = e.pageY;
}
if (isIE) {
_x = event.clientX + document.body.scrollLeft;
_y = event.clientY + document.body.scrollTop;
}
alert(_x);
alert(_y);
}
You can Use following code for Capturing the Mouse coordinates as per Screen Resolution
function getMousePositionScreenWise() {
var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;
var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;
alert(ScrY);
alert(ScrX);
}
Following script Will tested and working on following browsers.1. Firefox 2+2. Google chrome 3. Safari4. IE 6, 7, 85. Opera
You can Use following code for Capturing the Mouse coordinates as per Document bodyvar isIE = document.all?true:false;// document.onmousemove = getMousePosition;// document.onmousemove = getscreenPosition;
function getMousePositionBrowsersizeWise(e) { // as per Document body  var _x;  var _y;  if (!isIE) {    _x = e.pageX;    _y = e.pageY;  }  if (isIE) {    _x = event.clientX + document.body.scrollLeft;    _y = event.clientY + document.body.scrollTop;  }
alert(_x);alert(_y);  }
You can Use following code for Capturing the Mouse coordinates as per Screen Resolution
function getMousePositionScreenWise() {var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;
alert(ScrY);alert(ScrX);
}

Following script Will tested and working on following browsers.1. Firefox 2+2. Google chrome3. Safari4. IE 6, 7, 85. Opera
You can Use following code for Capturing the Mouse coordinates as per Document body
var isIE = document.all?true:false;// document.onmousemove = getMousePosition;// document.onmousemove = getscreenPosition;function getMousePositionBrowsersizeWise(e) { // as per Document bodyvar _x;var _y;if (!isIE) {_x = e.pageX;_y = e.pageY;}if (isIE) {_x = event.clientX + document.body.scrollLeft;_y = event.clientY + document.body.scrollTop;}alert(_x);alert(_y);}

You can Use following code for Capturing the Mouse coordinates as per Screen Resolution
function getMousePositionScreenWise() {var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;alert(ScrY);alert(ScrX);}Following script Will tested and working on following browsers.1. Firefox 2+2. Google chrome 3. Safari4. IE 6, 7, 85. Opera
You can Use following code for Capturing the Mouse coordinates as per Document bodyvar isIE = document.all?true:false;// document.onmousemove = getMousePosition;// document.onmousemove = getscreenPosition;
function getMousePositionBrowsersizeWise(e) { // as per Document body  var _x;  var _y;  if (!isIE) {    _x = e.pageX;    _y = e.pageY;  }  if (isIE) {    _x = event.clientX + document.body.scrollLeft;    _y = event.clientY + document.body.scrollTop;  }
alert(_x);alert(_y);  }
You can Use following code for Capturing the Mouse coordinates as per Screen Resolution
function getMousePositionScreenWise() {var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;
alert(ScrY);alert(ScrX);
}

Limit of QueryString / GET / URL parameters

Servers should be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations may not properly support these lengths.

The spec for URL length does not dictate a minimum or maximum URL length, but implementation varies by browser. On Windows: Opera supports ~4050 characters, IE 4.0+ supports exactly 2083 characters, Netscape 3 -> 4.78 support up to 8192 characters before causing errors on shut-down, and Netscape 6 supports ~2000 before causing errors on start-up.

Checking value from array javascript

I found usefull following URL working with Javascript Array.
http://www.javascriptkit.com/jsref/arrays.shtml

Here is my code to check value from array

var MyArrayVar = new Array(1, 2, 3, 4, 5);

testVar = 2;

if(MyArrayVar.indexOf(testVar) >= 0) {
alert(“We got testVar in MyArrayVar”);
}else{
alert(“We did not got testVar in MyArrayVar”);
}

As per this condition I am chekcing the What is returned by this MyArrayVar.indexOf(testVar).
You can check this by using “alert(MyArrayVar.indexOf(testVar));” line.
You will get this number value if testVar number or value present in Array.

You that value is not present in Array you will get the -1 result always.

How to Add or Remove the javascript file using javascript function

We can use following functions for adding the Javascript file dynamically.
function AddJsFile(file) {
var script = document.createElement(‘script’);
script.src = file;
script.type = ‘text/javascript’;
script.defer = true;

document.getElementsByTagName(‘head’).item(0).appendChild(script);
}

Or We can use this also, both will work:
function AddJsFile(file)
{
document.write(”);
}

We can use following functions for adding the CSS file dynamically.

function AddCssFile(file) {
var stylesheet = document.createElement(‘link’);
stylesheet.href = file;
stylesheet.type = ‘text/css’;
stylesheet.defer = true;

document.getElementsByTagName(‘head’).item(0).appendChild(stylesheet);
}

Or We can use this also, both will work:
function AddCssFile(file)
{
document.write(”);
}

We can use the following code for remving the JS the files.

function RemoveJsFile(file) {
var alljs = document.getElementsByTagName(“js”)
for (var i = alljs.length; i >= 0; i–) {
if (alljs[i] && alljs[i].getAttribute(“src”)!= null && alljs[i].getAttribute(“src”).indexOf(file)!=-1)

alljs[i].parentNode.removeChild(alljs[i])
}

}

We can use the following code for remving the CSS the files.
function RemoveCssFile(file) {
var allcss = document.getElementsByTagName(“css”)
for (var i = alljs.length; i >= 0; i–) {
if (allcss[i] && allcss[i].getAttribute(“href”)!= null && allcss[i].getAttribute(“href”).indexOf(file)!=-1)

allcss[i].parentNode.removeChild(allcss[i])
}

}