469,282 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Help

How can i get the present filename (the opened html) and print it in the
html (this html)?
thx
Jul 20 '05 #1
6 6340
"技安" <技安@技安•公司> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In article <ad**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
<script type="text/javascript">
write(location.pathname);
</script>


object expected :)

document.write(location.pathname);
perhaps?
--
Randy
Jul 20 '05 #3
hi************@aol.com (HikksNotAtHome) writes:
object expected :)

document.write(location.pathname);
perhaps?


Doh. Yes. Not window.write.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
"技安" wrote:
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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #5
??
what is the difference between this two method?
sorry, i m new user, maybe ask a stupid question...
thx

"Grant Wagner" <gw*****@agricoreunited.com> ???
news:3F***************@agricoreunited.com ???...
"技安" wrote:
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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html

Jul 20 '05 #6
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).

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

"Grant Wagner" <gw*****@agricoreunited.com> ???
news:3F***************@agricoreunited.com ???...
"技安" wrote:
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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Tom | last post: by
6 posts views Thread by wukexin | last post: by
3 posts views Thread by Colin J. Williams | last post: by
7 posts views Thread by Corepaul | last post: by
5 posts views Thread by Steve | last post: by
8 posts views Thread by Mark | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.