Forum Moderators: open
I have a frameset (It's a good use of them, I swear), with two rows, and the bottom row has two columns, for a total of three frames. This sums it up, I think:
----------------------
¦ top ¦
----------------------
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ list ¦ pages ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
----------------------
"list" is a list of links, but they're generated from a fairly crappy custom CMS, so I have no control over the formatting of the actual links.
I have the target set for that frame to be the frame "pages."
In "top," I have a textarea. Firefox has a nice behavior where if I drag a link from pages to the textarea in top, it puts the URL of the link on one line, and the text of the link on the next. IE doesn't even let me drag the links. Typical.
This works ok, but I'd like to have the URL show up in that textarea when I click it.
Is this possible?
As a bonus, would it be possible to have the text of the link go up there too, like what happens when I drag the link in Firefox?
As an even bigger bonus, would it be possible to strip part of the URL out? Instead of [blahblahblah.com...] could I just have /whatever/something/this.html show up?
Am I asking too much?
let's say you have got three frames
<html>
<head>
<title>Nouvelle page 1</title></head>
<frameset rows="64,*">
<frame name="banner" scrolling="no" noresize>
<frameset cols="468,*">
<frame name="menu" src="nouvellepage2.htm">
<frame name="principal" src="nouvellepage3.htm">
</frameset>
<noframes>
I swear it is good usage of frames
</noframes>
</frameset>
</html>
[code]
for example you could access an input in principal from menu by a link in nouvellpage2.htm as follows:
<a [code]onclick="parent.principal.document.getElementById('myinput').value='hello'">fsdf</a>
with an input in nouvellepage3.htm:
<input type='text' id='myinput' />
I've got a test link with this code...
<a href="page.html" onclick="parent.topframe.document.getElementById('thebox').value=href+' '+' '+'Good, it works'">Test link</a>
This gives me this result when I click it...
http://www.theurlofthepage.com/thepage.html Good, it works
This is a great start, I think.
Next, is it possible to apply this to the whole page (or at least in certain parts of the page) without having to edit every actual link? I ask because I have no control over the formatting and code of the actual links, due to them being generated by a crappy content management system. Can I have this apply to links in a div or the whole document?
Also, how about having it write the actual link text?
And last, how do I tell javascript to put the second part on another line? I can't just tell it to write a line break, because that'll write that in the text area, right?
You're a huge help so far guys!
I'm working with this simple script...
<script language="JavaScript"><!--
function functionName(text) {
}
//--></script>
And this is my link:
<a href="page.html" onclick="parent.topframe.document.getElementById('thebox').value=href+'\r'+this.text">Another test link</a> It gives me this result in Firefox:
[whatever.com...]
Another test link
Firefox does it right. In IE, the second line just comes up as undefined. Is there an error that I'm missing? It's not a huge deal since 99% of the time, I'll be the only person who will using this particular page.
The real issue I'm now faced with is getting every link on the page to do this by default. How could I do that?
function routine(...) { ...
target-var-array=parent.targetframe.documument.getElementsByTagName('text'); for (i=0; i<target-var-array.length; i++) { j=target-var-array[i]; if (j.id=='myinput') { j.value='mynewvalue'; break; } /* end of loop */; } /* end of function */; }
!be careful of case on getElementsByTagName or other such functions...I used the name routine above, you'll change it, of course!