Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 6th, 2004, 09:22 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default get URL

Hello.

How can I open a document that is already opened in a frame of a page in a new window with a function like newWindow(). How can I get its URL and put it as a content in the new window?
Thanks.

 
Old February 6th, 2004, 09:43 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If the frame is named 'main' and the document is from the same domain as the one in which you are running code then:
Code:
var sUrl = top.frames['main'].location.href;
alert(sUrl); //Debugging
gives you the URL and then:
Code:
window.open(sUrl);
--

Joe
 
Old February 6th, 2004, 10:27 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot by your reply, Joe, but I'd like to get the current URL shown in the page, from any site. Do you know how to do this too?
Thanks again.


 
Old February 6th, 2004, 10:50 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Using standard code you can't, it's a security restriction. In a low security setting you can using the shell.application class. Search google groups for examples containing that class within the last two years authored by myself, Joe Fawcett. I don't have the stuff with me at the moment because I'm away from office. Basically you create a shell.application and loop through the collection retuned by its windows method. Thos gives all open windows and you can examine url's etc.

--

Joe
 
Old February 6th, 2004, 11:33 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again. I was thinking we had a simple way to get there... I'll try a "workaround". Thanks, Joe.







Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Redirect based on given URL somnath.kartic VS.NET 2002/2003 1 August 2nd, 2012 08:21 AM
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
URL MunishBhatia ASP.NET 2.0 Professional 4 May 11th, 2007 10:31 AM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM
Url Help morpheus Classic ASP Basics 2 January 27th, 2004 12:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.