Forum Moderators: open
document.write(" <a href=http://www.linkedpage.htm target=gf onClick=fgf = window.open('','gf');fgf.focus()>
(followed by - but less important)
<font size=<? echo "$fontsize" ;?> color=#<? echo "$titlefontcolor" ;?> face=<? echo "$fonttype" ;?>>Recent Studies:</font></a>");
the function fgf just opens the linked page in a new window. I know there isnt much code there to play with but i know the problem is just something like missing " or something. the mixture of 3 languages in causing the problems, cause php has " as a special character. anyone have any suggestions on how to make this line of code work?
"onlick=fgf = window.open('','gf');" - this part is where im guessing the problem arises cause of the two equals signs... any ideas anyone?
1. The attribute values aren't quoted, IE won't be worried about that, certainly with an HTML DTD, so we could let that pass, except for the onClick handler. I think you can get away with it evn there, but it might be best to quote the value there, especially since there is more than one statement. One of them has an = character - that may play a big part in things (It does, see below).
2. The open method takes 3 args. Leaving one out may irritate.
< after some checks >
the function fgf just opens the linked page in a new window
Not quite. When it's working correctly, fgf isn't a function, it's a global var that holds a reference to the new window (The function is actually anonymous). When IE parses the event handler without quotes, it discards everything after onClick = fgf (the 2nd = sign is interpreted as an error).
Ironically, this means that fgf is assumed to a function to call when the link is clicked...and it's not a function - it's not even defined, hence the error.
Here's what works for me. I still have only quoted the event handler value, but I have added the 1st arg to window (just for safety), and a blank 3rd arg. Remove these amendments if you like. I also added the link text, and closing </a> , just for demo purps.
document.write(
" <a href=http://www.linkedpage.htm target=gf onClick=\"fgf=window.open(this.href,'gf','');fgf.focus();\">link</a>"
)
[edited by: Bernard_Marx at 12:04 pm (utc) on Aug. 25, 2004]