473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
4 1499

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

Jul 6 '06 #2
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: gb | last post by:
Hi All, Ive created a popup page using 'var openWindow = window.open("new","pop")' And added content using openWindow.document.write(" "); statements. But now I would like to be able to print...
20
by: John Bokma | last post by:
Hi, I converted most (not all) of my pages at http://johnbokma.com/ to XHTML. I thought this was just a small change from 4.01. However someone stated quite vaguely that my pages are *not*...
13
by: Ben Sharvy | last post by:
Is there a list of the changes you need to make to HTML 4.1 cose to make it dual compliant, with XHTML 1.1 also?
0
by: David Spencer | last post by:
Here you can find a good tool for chm creation http://abeetech.com/chmmakerpro/ You must not to create subdirectories. Just add all your html-files from one directory and structurize the TOC as...
5
by: Tom | last post by:
I have a subreport that can contain one or two pictures per page. The subreport is similar to an appendix to the main report. The recordsource contains a field "IncludeInReport" (Yes/No) for each...
2
by: LilBuh | last post by:
hi there :) i ve been looking for some time a way to print an html file from vb.net i came up with this code for printing and removing the header and footer from IE then once the printing is done...
13
by: Peter Williams | last post by:
Hello, If my html is valid XHTML accroding to http://validator.w3.org/, does thuis mean it is also valid (4.0.1) Html? Thanks in Advance
0
by: dotnet2005 | last post by:
Hi Toall , I want to explain you clearly , I am having some panels having some controls CheckBox,ComboBox,Datagridview,Hyperlink,label,Listbox,Picturebox,RadioButt­ on ,Textbox)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.