Noob: popus, frames and forms

H

henry

I'm hoping this won't be too hard with Javascript (I'm new to the
language).

I've got a page with a form on it (name=frm1) which has a text input
(name=url).
I want to be able to click a link that will open a popup that has 2
frames. The top frame (frameA) will have a button/link that, when
clicked, will do 2 things:
1. Insert the URL of frameB (the bottom frame) into the text box "url"
on the original page
2. Close the popup


Here's my setup so far:
change.shtml has
<head>
<!-- Script
function load() {
var load =
window.open('changeurl.html','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}
// -->
</Script>
</head><body>
<a href="javascript:load()">Click here</a>

changeurl.html simply sets up the two frames, frameA (changea.html) and
frameB (www.domain.com)

changea.html is where I need the button that does the above 2 points.
(No idea how to make this page).

I appreciate any help,

henry
 
L

Lee

henry said:
I'm hoping this won't be too hard with Javascript (I'm new to the
language).

I've got a page with a form on it (name=frm1) which has a text input
(name=url).
I want to be able to click a link that will open a popup that has 2
frames. The top frame (frameA) will have a button/link that, when
clicked, will do 2 things:
1. Insert the URL of frameB (the bottom frame) into the text box "url"
on the original page
2. Close the popup


Here's my setup so far:
change.shtml has
<head>
<!-- Script

Get rid of that comment line.
Insert:
function load() {
var load =
window.open('changeurl.html','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}

There's no reason to assign the returned value to any variable.
There's no need to specify attributes that you're setting to "no".
As long as you are setting any others, all unspecified attributes
default to "no". Some browsers [used to?] require a window name.
On the plus side, it's very good that you make it resizable.

window.open("changeurl.html",
"myPopup",
"height=600,width=800,resizable");

Get rid of that comment, too.
</Script>
</head><body>
<a href="javascript:load()">Click here</a>

Don't use the javascript: pseudo-protocol if you can avoid it:

<a href="#" onclick="load();return false">Click here</a>

Returning false from the onclick handler prevents the link from
being followd. (It would be best to replace "#" with some
meaningful URL to be loaded by people who don't have scripting
enabled).

changeurl.html simply sets up the two frames, frameA (changea.html) and
frameB (www.domain.com)

Now the bad news. Your top frame doesn't have permission to read
the URL of the bottom frame unless it's coming from the same server.
It's a security issue to prevent people from browsing in a popup
without realizing it and allowing somebody to track their movements.

Otherwise, the onclick handler of the button in the top frame would
be something like:

top.opener.document.forms[0].url.value=top.frameB.document.location.href;
 
H

henry

So now in change.shtml I have:
<html><head>
<script type="text/javascript">
function load() {
var load =
window.open("changeurl.html",
"myPopup",
"height=600,width=800,resizable");
}
</Script>
</head><body>
<form name="frm1" action="change.pl" method="post">
<a href="#" onclick="load();return false">Click here</a>
<input type='text' size=60 name='url' value='http://www.'>
</form>
</body></html>

And in changea.html I have:
<html><head>
<script language="JavaScript">
function closeWindow() {

top.opener.document.forms[0].url.value=top.frameB.document.location.href;
top.window.close();
}
</script>
</head><body>
<form>
<input type=button value="Close Window" onClick="closeWindow();">
</form>
</body></html>

The content of frameB will be on the same server so that's ok. But this
doesn't work. It doesn't insert the value or close the window. What
have I done wrong?
Thanks again,

Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top