|
Posted by Mitja Trampus on 11/17/05 23:37
David Blickstein wrote:
> Is there a way in HTML to generate the URL of "this" page. I have a page
> which moves around a lot and happens to be co-located with stuff that people
> need to copy the URL of into an installation.
>
> I'd rather have it just print the URL rather than awkward text that says
> "take the URL of this page and..."
Just HTML, no. With javascript, yes, but make sure you don't
make javascript a neccessity for understanding the
instructions because it can be disabled.
Do something like:
<body onload="updateContentsOfLocalUrlSpanWithCurrentUrl()">
<p>
Take the URL of this page (<span id="localUrl">copy-paste
from address bar</span>) and do foo with it.
</p>
The JS function you need is simple, an one-liner:
document.getElementById("localUrl").innerHTML = location.href
Note that this piece of JS is far from perfect (regarding
cross-browser issues), but I'm not exactly an expert on that.
Navigation:
[Reply to this message]
|