printing HTML with appendix showing links, URL etc...

Q

qwweeeit

Hi all,
I'm a newbie in JS, but I've used it to print html
+ additional informations:
- list of links (also internals)
both text (document.links.text) and href
- title (document.title)
- URL, domain and referrer
- cookie
- last modification date (document.lastModified)

But to insert the script into the document (appending it), you
have to save it on your hard disk.
Unfortunately that causes alteration of internal links
and of most part of the other informations, and mainly
URL which becomes file:///....
How can I get the correct URL (the most important info) and the other
data? Are there security problems?
Thanks.
Bye.
 
Q

qwweeeit

Hi,
as requested, this is the script to be appended
to the html file to be printed:


<script type="text/javascript">
var len = document.links.length; /
document.write("<hr size='2'>");
document.write("<table width=100%>");
document.write('<pre>')
document.write('title * '+document.title + '<br>');
document.write('URL * '+document.URL + '<br>');
document.write('domain * '+document.domain+'<br>');
document.write('referrer * '+document.referrer + '<br>');
document.write('cookie * '+document.cookie + '<br>');
document.write('lastModified * '+document.lastModified + '<br>');
document.write('</pre>')
/*
title * CUPS Software Users Manual
URL * file:///home/qwweeeit/href/pippo.html
domain *
referrer *
cookie *
lastModified * 06/30/2006 12:14:46 PM
*/

for(var i = 0; i < len; i++){
document.write("<tr><td align='right' width='2%'>"+(i + 1) +
".</td>");
sLink=document.links.href;

if (sLink.substring(0,32)== 'file:///home/bf/href/pippo.html#'){
document.write("<td width='98%'>"+document.links.text+ '
('+sLink.replace('file:///home/bf/href/pippo.html#','#')+')</td></tr>');
}
else {
document.write("<td
width='98%'>"+document.links.text+"</td></tr>");

document.write("<tr><td width='2%'> </td>");
document.write("<td
width='98%'>"+document.links.href+"</td></tr>");
}
}
document.write("</table>");
</script>

As you can see (commented) the URL is completely wrong.
I made a small bash script to run all.
Bye
 
Q

qwweeeit

Hi,
the problem is that I did not specify "on the client side"!
You inserted my script on a html document (1.htm) on your web server.
Of course it works... now we have only to ask all web servers
in the world to append my script to every single html file!
Out of joke... I think that there is a security issue.
Can't we save the original URL, and recover it afterwards?
Bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top