By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,575 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,575 IT Pros & Developers. It's quick & easy.

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

P: n/a
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[i].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.

Jul 6 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Show an example, please... It's not obvious what you want to do.

Jul 6 '06 #2

P: n/a
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[i].href;

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

document.write("<tr><td width='2%'</td>");
document.write("<td
width='98%'>"+document.links[i].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

Jul 6 '06 #3

P: n/a
Look here:
http://mertas.cat-a-log.ru/1.htm
This is your script and all links are right...
Maybe there is a problem with your server?
Or is it my misunderstanding?

Jul 6 '06 #4

P: n/a
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.

Jul 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.