RSS

Get js css source of web page

11 Apr

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&#91;i&#93;.src) { add(makeText('h4','script src=&quot;' + s&#91;i&#93;.src + '&quot;'),b);
iframe=makeTag('iframe'); iframe.src=s&#91;i&#93;.src; add(iframe,b); } else { add(makeText('h4','Inline script'),b);
add(makeText('pre', trim(s&#91;i&#93;.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&#91;i&#93;.href) { add(makeText('h4','style href=&quot;' + s&#91;i&#93;.href + '&quot;'),b);
iframe=makeTag('iframe'); iframe.src=s&#91;i&#93;.href; add(iframe,b); } else { add(makeText('h4','Inline style'),b);
add(makeText('pre', trim(s&#91;i&#93;.innerHTML)),b); } }

for(i=0; i<s1.length; ++i) { if (s1&#91;i&#93;.href) { add(makeText('h4','style href=&quot;' + s1&#91;i&#93;.href + '&quot;'),b);
iframe=makeTag('iframe'); iframe.src=s1&#91;i&#93;.href; add(iframe,b); } else { add(makeText('h4','Inline style'),b);
add(makeText('pre', trim(s1&#91;i&#93;.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;
}

Advertisements
 
1 Comment

Posted by on April 11, 2009 in Ajax, javascript, php

 

Tags: , , , , ,

One response to “Get js css source of web page

  1. Citroorpwat

    May 22, 2009 at 9:39 am

    Looking for Florida university sport? Funny fantasy sport names is here http://blogprosport.com/ !
    .

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: