Forum Moderators: open
I had a thread going a while ago on this. I got it working perfectly, but recently, something weird started happening, and it no longer works.
I have this script...
<script type="text/javascript">function addClick(){
for (i=0;i<document.links.length;i++){
var hHref=document.links[i].getAttribute("href")
var lTxt=document.links[i].text;
document.links[i].setAttribute("onclick","intercept('"+hHref+"','"+lTxt+"')");
}
}
function intercept(hRef,lTxt){
parent.topframe.document.getElementById('thebox').value=hRef+'\r'+lTxt;
}
</script>
Basically, it writes some stuff to a textarea in another frame when I click it. It had been working great, for the most part (on some links it doesn't work -- no idea why).
Some change on the server that I can't control must have made something screw up recently, however. The script still does its thing, but I also have the <base target="pages"> to open the links in the frame named pages. That stopped working suddenly. No clue why.
So what I want to do now, is add a line to the javascript to handle it.
I tried adding this line:
top.frames['page'].location='href';return true;"; That works, but then the part that writes to the textarea stops working. Can you help me get it to do both?
HTML
<a href="http://www.example.com" class="externallink" rel="external">Example Site</a>
script-target.js
function externalLinks()
{
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
var map = {external:"_blank", border:"border",mplayer:"mplayer"};
var anchor, i, target;for (i=0; anchor=anchors[i++];)
if( anchor.getAttribute("href") && (target=map[anchor.getAttribute("rel")]))
anchor.setAttribute("target", target);}
window.onload = externalLinks;
In case you're wondering, this is the hideous code that it spits out at me:
<P CLASS="list">•
<A HREF="/asdf/asdf/asdf.xml"><B>Innovations distinguished old theater</B></A>
<BR> In its early years, the Senate Theater sparkled with first-run films, visits by Hollywood celebrities and top-notch promotions. <BR>
</P>
I could go on for hours about how many things I can find that are awful about that, but it would do me little good, since I don't control it. If I could just put it all in the link, I would. That's why I need to do it with a Javascript.