HighDots Forums  

Adding text to a textbox from a pop-up-window.

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Adding text to a textbox from a pop-up-window. in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
R.Wieser
 
Posts: n/a

Default Adding text to a textbox from a pop-up-window. - 05-22-2006 , 06:16 AM






Hello All,

I'm trying to create a "tool" that adds some a functionality to a website.

Currently I just have two frames, off of which the left one is my own, local
"short-cut" menu, and the right frame the websites contents, a forum.

In that forum I can respond to messages, for which it shows a textbox.

What I would like to do is to click on pieces of text that are in a
popup-box which is initiated from the frame on the left, and have them than
copied to the textbox in the frame on the right.

So, the path is : Pop-up box -> frame on the left -> main page -> frame on
the right -> textbox

Alas, my knowledge of JS is still in its infant stage, and I have no idea
how to do this (nonwithstanding my searches on the Web for an answer).

Could anyone explain to me what has to be done ? Pointers to information
about the why of it would be nice too :-)

Regards,
Rudy Wieser




Reply With Quote
  #2  
Old   
R.Wieser
 
Posts: n/a

Default Re: Adding text to a textbox from a pop-up-window. - 05-22-2006 , 12:17 PM






Wayne Dobson <nospam (AT) noadress (DOT) com> schreef in berichtnieuws
dXkcg.319561$8Q3.129552 (AT) fe1 (DOT) news.blueyonder.co.uk...

Hello Wayne,

<snip>

Quote:
The small window that opens when you click on the words
in the left frame, allows you to select from that text in that
window, then either drag and drop, or cut and paste.
Thank you for your reply, together with its (more than expected) full
example.

Although neither my (old) version of IE and my current version of FireFox
understood the line [ <B id="newWindow" target="about:blank">Click To Open
Window</B> ] (which I had to change to a simple [ <A
href=javascriptpen(...)> ...</a> ] ), it worked perfectly.

There is just one thing : I hoped to be able to *click* on an icon or piece
of text, and that it would be added to a specific textbox in the
target-frame (making the whole thing a one-click thing, whatever the
contents).

Is there any chance you have the solution to that one as well ? :-)

Regards,
Rudy Wieser

P.s.
I'm saving your current post, so I can look at it when I need something
similar. :-)





Reply With Quote
  #3  
Old   
Wayne Dobson
 
Posts: n/a

Default Re: Adding text to a textbox from a pop-up-window. - 05-23-2006 , 09:32 AM




"R.Wieser" <address (AT) not (DOT) available> wrote

Quote:
Wayne Dobson <nospam (AT) noadress (DOT) com> schreef in berichtnieuws
dXkcg.319561$8Q3.129552 (AT) fe1 (DOT) news.blueyonder.co.uk...

Hello Wayne,

snip

The small window that opens when you click on the words
in the left frame, allows you to select from that text in that
window, then either drag and drop, or cut and paste.

Thank you for your reply, together with its (more than expected) full
example.

Although neither my (old) version of IE and my current version of FireFox
understood the line [ <B id="newWindow" target="about:blank">Click To Open
Window</B> ] (which I had to change to a simple [ <A
href=javascriptpen(...)> ...</a> ] ), it worked perfectly.

There is just one thing : I hoped to be able to *click* on an icon or
piece
of text, and that it would be added to a specific textbox in the
target-frame (making the whole thing a one-click thing, whatever the
contents).

Is there any chance you have the solution to that one as well ? :-)

Regards,
Rudy Wieser

P.s.
I'm saving your current post, so I can look at it when I need something
similar. :-)
Replace the javascript between the "SCRIPT" tags, in the respective files
to:

***********************************************
Frame1.html
***********************************************

var b = document.getElementById("newWindow")
b.style.cursor = "pointer"
b.onclick = function()
{
var win =
open("smallwindow.html","smallwindow","titlebar=no ,height=200,width=200")
win.test = window
win.focus()
}

***********************************************
smallwindow.html
***********************************************

new TextTransfer("selectedText","destination")

function TextTransfer(from,dest)
{
this.click = function()
{
var doc = window.test.parent.frames[1].document
doc.getElementById(this.dest).value = this.firstChild.data
}
var b = document.getElementById(from).getElementsByTagName ("B")
for( var i = 0 ; i < b.length ; i++ )
{
b[i].dest = dest
b[i].style.cursor = "pointer"
b[i].onclick = this.click
}
}

--
Wayne
AKA "Dobbie the House Elf"




Reply With Quote
  #4  
Old   
R.Wieser
 
Posts: n/a

Default Re: Adding text to a textbox from a pop-up-window. - 05-25-2006 , 02:48 AM



Wayne Dobson <nospam (AT) noadress (DOT) com> schreef in berichtnieuws
f2Fcg.189636$tc.167703 (AT) fe2 (DOT) news.blueyonder.co.uk...

Hello Wayne,

<snip>

Quote:
There is just one thing : I hoped to be able to *click* on an
icon or piece of text, and that it would be added to a specific
textbox in the target-frame (making the whole thing a one-
click thing, whatever the contents).
<snip>

Quote:
Replace the javascript between the "SCRIPT" tags, in the
respective files to:
<snip>

Thanks. Although I could not get that code to work, it gave me an idea to
in which way I should look.

And as you will have it, the end-result wanted to work on three local files,
but would not when I replaced the right frame with an real URL (FireFox told
me that access was denied, something I can even understand).

Again, thanks for the help, you gave me a push in the right direction. :-)

Regards,
Rudy Wieser





Reply With Quote
  #5  
Old   
Wayne Dobson
 
Posts: n/a

Default Re: Adding text to a textbox from a pop-up-window. - 05-25-2006 , 07:34 AM



"R.Wieser" <address (AT) not (DOT) available> wrote


Quote:
Thanks. Although I could not get that code to work, it gave me an idea
to
in which way I should look.

And as you will have it, the end-result wanted to work on three local
files,
but would not when I replaced the right frame with an real URL (FireFox
told
me that access was denied, something I can even understand).
I just tried it in Firefox. It worked fine.

Quote:
Again, thanks for the help, you gave me a push in the right direction. :-)
No problem. :-)

--
Wayne
AKA "Dobbie the House Elf"




Reply With Quote
  #6  
Old   
R.Wieser
 
Posts: n/a

Default Re: Adding text to a textbox from a pop-up-window. - 05-25-2006 , 08:26 AM



Wayne Dobson <nospam (AT) noadress (DOT) com> schreef in berichtnieuws
2vhdg.205270$tc.151264 (AT) fe2 (DOT) news.blueyonder.co.uk...

<Snip>

Quote:
I just tried it in Firefox. It worked fine.
But that still does not mean it works over here :-)

The returned message was : "Error: uncaught exception: Permission denied to
get property HTMLDocument.title".

The used code was :
-------------------------------------------
var b = top.opener.top.frames
for( var i = 0 ; i < b.length ; i++ ) {
confirm("--"+i+" "+b[i].document.title);
}
-------------------------------------------
It did show the left frame (frame #0), which is a local file, but barfed at
the right-frame, which is a real URL.

It has probably something to do with inter-site navigation and a lack of
security when that happens. I have to see if I can find more on that
subject (something like alliviating the restrictions for JS when certain
"web"-pages are the source)

Regards,
Rudy Wieser





Reply With Quote
  #7  
Old   
Wayne Dobson
 
Posts: n/a

Default Re: Adding text to a textbox from a pop-up-window. - 05-25-2006 , 09:23 AM



"R.Wieser" <address (AT) not (DOT) available> wrote

Quote:
Wayne Dobson <nospam (AT) noadress (DOT) com> schreef in berichtnieuws
2vhdg.205270$tc.151264 (AT) fe2 (DOT) news.blueyonder.co.uk...

Snip

I just tried it in Firefox. It worked fine.

But that still does not mean it works over here :-)

The returned message was : "Error: uncaught exception: Permission denied
to
get property HTMLDocument.title".

The used code was :
-------------------------------------------
var b = top.opener.top.frames
for( var i = 0 ; i < b.length ; i++ ) {
confirm("--"+i+" "+b[i].document.title);
}
-------------------------------------------
It did show the left frame (frame #0), which is a local file, but barfed
at
the right-frame, which is a real URL.
There certain actions which you will never be allowed to perform from a
frame which does not originate from the same domain. You can call up any
page into a different frame, but you may not always be allowed to read from
or write to it. You could have a click, copy information to the clipboard,
then manually paste it.

Quote:
It has probably something to do with inter-site navigation and a lack of
security when that happens. I have to see if I can find more on that
subject (something like alliviating the restrictions for JS when certain
"web"-pages are the source)
Here's what Microsoft has to say:
http://msdn.microsoft.com/library/de...node_entry.asp

--
Wayne
AKA "Dobbie the House Elf"




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.