Help

§

§Þ¦w

How can i get the present filename (the opened html) and print it in the
html (this html)?
thx
 
L

Lasse Reichstein Nielsen

§Þ¦w said:
How can i get the present filename (the opened html) and print it in the
html (this html)?

<script type="text/javascript">
write(location.pathname);
</script>

This includes the path. You'll have to cut it away if you don't want it.

/L
 
G

Grant Wagner

§Þ¦w said:
How can i get the present filename (the opened html) and print it in the
html (this html)?
thx

var protocol = window.location.protocol;
var path = window.location.pathname;
// this is required because IE loading files locally uses "\" and not "/"
var separator = (protocol == "file:" && path.indexOf("/", 1) == -1 ? "\\" :
"/");
var path = window.location.pathname;
var file = path.substring(path.lastIndexOf(separator) + 1);
document.write(file);



--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
?

??

what is the difference between this two method?
sorry, i m new user, maybe ask a stupid question...
thx
 
G

Grant Wagner

Between what two method? The code I provided in a single solution that provides the
functionality you originally required (to output the filename of the current file loaded
into the browser).

?? said:
what is the difference between this two method?
sorry, i m new user, maybe ask a stupid question...
thx

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

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
474,082
Messages
2,570,588
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top