Displaying Current Page URL for User

June 13, 2009 at 20:48:26
Specs: Vista x64, N/A
As part of our website, we have a phpBB forum that runs in an iframe. This works fine for our setup, but produces one problem; when viewing a post/topic/whatever, the specific page URL is not visible, and instead the visitor only sees the frameset page URL in the address bar.

I have added a link on the bottom over every phpBB page, which, when clicked, calls the JavaScript "prompt" and displays the current page URL in the prompt's text field. This allows the user to copy the URL if desired.

This doesn't work as well as I would like, as IE7+ (and some other browsers) block the JavaScript window.prompt function by default.

Any other ideas on how to display the URL of the current page in a way that will allow the user to copy it?

-Ryan Adams
Free Computer Tips and more:http://RyanTAdams.com

Paid Tech Support: Black Diamond

See More: Displaying Current Page URL for User

Report •

June 15, 2009 at 07:58:06
Hey Ryan,

Dunno if it is what you need, if it will help, or how browser compatible it is, but I ran a quick test on my own test forum using.

<script language="javascript">

function update() {

   var d = document.getElementsByTagName("iframe")["ifrm"].contentWindow.document.location;
   document.getElementById("loc").innerHTML = d;
   document.getElementById("loc").href = d;

setInterval('update()', 2000);


<body onload="update()">
<a id="loc" href=""></a>
<iframe name="ifrm" src="mboard/" width="900" height="500"></iframe>

The link *will* open the iframe's current uri in the browser. The downside is the iframe and the default page must reside in the same domain or you'll get an access denied type of error... you'll get the error using sub domains as well as I recall.


Report •
Related Solutions

Ask Question