Computing.Net > Forums > Web Development > Displaying Current Page URL for User

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Displaying Current Page URL for User

Reply to Message Icon

Name: RTAdams89
Date: June 13, 2009 at 20:48:26 Pacific
OS: Vista x64
CPU/Ram: N/A
Subcategory: Javascript/Ajax
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: shutat
Date: June 15, 2009 at 07:58:06 Pacific
Reply:

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.

<html>
<head>
<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);

</script>
</head>

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

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.

HTH


0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Displaying Current Page URL for User

getting page url www.computing.net/answers/webdevel/getting-page-url/2925.html

Site Development Estimate www.computing.net/answers/webdevel/site-development-estimate/2120.html

Time For A Change... www.computing.net/answers/webdevel/time-for-a-change/104.html