PDA

View Full Version : How to print the document name using document.write


jrgeoffrion
02-12-2003, 05:39 AM
Hi,

I'm trying to get the first and second character of the file in use to print in the window.

For example, if my document is called 01weddings.shtml, I would like to have 01 printed.

My guess is that the code would look like this... but I'm missing an argument/attribute


<SCRIPT LANGUAGE="JavaScript">
<!--

document.write(document.____.CharAt(0) + document.____.CharAt(1));

// -->
</SCRIPT>

Any one can help?

Feel free to post or e-mail me.

Regards,

JR

piz
02-12-2003, 08:43 AM
This is no attribute/argument, thats a property what you're searching.

You can use document.URL.
Then you have to filter the domain name and the directory - the full path - out to get the filename.

Saludo,
piz

jrgeoffrion
02-12-2003, 08:45 AM
Thx... Looks like it's the route I'm headed...

JR

ca_redwards
02-12-2003, 09:04 AM
Alternatively, you can use window.location or even window.location.href

:)

Originally posted by jrgeoffrion
Hi,

I'm trying to get the first and second character of the file in use to print in the window.

For example, if my document is called 01weddings.shtml, I would like to have 01 printed.

My guess is that the code would look like this... but I'm missing an argument/attribute


<SCRIPT LANGUAGE="JavaScript">
<!--

document.write(document.____.CharAt(0) + document.____.CharAt(1));

// -->
</SCRIPT>

Any one can help?

Feel free to post or e-mail me.

Regards,

JR