Location toolbar question

Posted on 2003-02-19
Medium Priority
Last Modified: 2010-04-09
Hello, I'm jbosch(vosk) and I would like to know if is there a way to get the location value,  and if is there a way to get the url from a iframe. Here is an example:
I have the main window with a textfield (or div, a, span, etc) named "A" and a iframe named "F". In the iframe there are some links to other pages or maybe a textfield named "B" and a button to open that new url. The user selects a link or enters a url and the iframe changes to the new url. What I want is display on the "A" textfield (or div, span,etc) from the main window that new url that the user has entered (maybe with a button, to get the new url). I have tryed with document.all.F.src but it always returns the predefined url.
That is the sample code to the main window:
<script language="JavaScript">
function veure()
var nova = document.all.F.src;
document.mainwindowform.A.value = nova;
<form name="mainwindowform">
Here I want to display the user-defined new url of the iframe:
<input type="text" name="A" value="" size="100">
<input type="button" name="B" value="URL" onClick="veure();">
<iframe id="F" src="firstiframepage.html" width="200" height="150">
And that is the same code for the iframe:
<form name="newurl">
<input type="text" name="B" value="">
<input type="button" name="C" value="new url" onClick="location = document.newurl.B.value">
I'm using MSIEv5.5
Question by:vosk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 17

Accepted Solution

dorward earned 80 total points
ID: 7980632

You could try document.all.F.document.location.href, but I expect that if the iframe has been sent to a different domain you will get failures (due to cross domain security features).

Author Comment

ID: 7980947
dorward: I have tryed with that but it returns the url of the predefined page used in the frame.
Do you know how I can get the value of a textfield placed in a iframe? I have tryed also that with document.all.F.document.formname.textfieldname.value but it returns an error.

Expert Comment

ID: 7983551
did you try:

document.frames(0).document.getElementById('elementid as string').value;

Author Comment

ID: 7987925
thomasdodds: I didn't try getElementById because I'm using MSIE, althought sometimes I use NSNv4.5, that version cannot use iframes.
Now I have read a cross-frame scripting and security and it tells the next:
window.location: property can be set to navigate, butc annot read.  
Other location: functionality is blocked.  
document.href: property can be set to navigate but cannot read.  
Other document: functionality is blocked.  
<IFRAME>: src property can be set to navigate but cannot read.
(and much more)
So I think that I can answer to myself saying that I cannot read a new url where an iframe has been redirected.
Thanks for both answers, but I'll give the points to dorward because was near to the right answer.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question