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

Help

P: n/a
How can i get the present filename (the opened html) and print it in the
html (this html)?
thx
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"技安" <技安@技安•公司> 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

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

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

P: n/a
"技安" 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

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

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