Get js css source of web page
These are some javascript functions which can be used for getting js, css files included on web page.
Also we can view source of these files……
function trim(s) {return s.replace(/^\s*\n/, '').replace(/\s*$/, ''); };
function add(h,b) {b.appendChild(h);}
function makeTag(t) {return document.createElement(t);}
function makeText(tag,text) {t=makeTag(tag); t.appendChild(document.createTextNode(text)); return t;}
function get_all_js(divid)
{
var s=document.getElementsByTagName('SCRIPT');
var d=window.document;
var b=document.getElementById(divid);
add(makeText('style', 'iframe{width:100%;height:18em;border:1px solid;'),b);
add(makeText('h3', d.title='Scripts in ' + location.href),b);
for(i=0; i<s.length; ++i) { if (s[i].src) { add(makeText('h4','script src="' + s[i].src + '"'),b);
iframe=makeTag('iframe'); iframe.src=s[i].src; add(iframe,b); } else { add(makeText('h4','Inline script'),b);
add(makeText('pre', trim(s[i].innerHTML)),b); } }
return b;
}
function get_all_css(divid)
{
var s=document.getElementsByTagName('LINK');
var s1=document.getElementsByTagName('STYLE');
var d=window.document;
var b=document.getElementById(divid);
add(makeText('style', 'iframe{width:100%;height:18em;border:1px solid;'),b);
add(makeText('h3', d.title='Styles in ' + location.href),b);
for(i=0; i<s.length; ++i) { if (s[i].href) { add(makeText('h4','style href="' + s[i].href + '"'),b);
iframe=makeTag('iframe'); iframe.src=s[i].href; add(iframe,b); } else { add(makeText('h4','Inline style'),b);
add(makeText('pre', trim(s[i].innerHTML)),b); } }
for(i=0; i<s1.length; ++i) { if (s1[i].href) { add(makeText('h4','style href="' + s1[i].href + '"'),b);
iframe=makeTag('iframe'); iframe.src=s1[i].href; add(iframe,b); } else { add(makeText('h4','Inline style'),b);
add(makeText('pre', trim(s1[i].innerHTML)),b); } }
return b;
}
function get_view_source(divid)
{
var s=document.getElementsByTagName('HTML');
var d=window.document;
var b=document.getElementById(divid);
add(makeText('style', 'iframe{width:100%;height:18em;border:1px solid;'),b);
add(makeText('h3', d.title='Source of ' + location.href),b);
for(i=0; i<s.length; ++i) { add(makeText('h4','View Source'),b);
add(makeText('pre', trim('<html>'+s[i].innerHTML+'<html>')),b); }
return b;
}
1 comment so far
Leave a reply
Looking for Florida university sport? Funny fantasy sport names is here http://blogprosport.com/ !
.