Forum Moderators: open

Message Too Old, No Replies

mixing html, javascript, php problem

         

hodgy

10:01 am on Aug 25, 2004 (gmt 0)

10+ Year Member



I am writing php program in which at a certain point i need to mix three languages, php, javascript and html in the same line. the output of what im doing is correct but i still get an error on page message in internet explorer.
here is the line of code:

document.write("&nbsp;<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?

BlobFisk

3:20 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I wonder if the problem is in this line:


document.write("&nbsp;<a href=http://www.linkedpage.htm target=gf onClick=fgf = window.open('','gf');fgf.focus()>

You're not using quotes around your hred, target and onclick. While these can be omitted they really shouldn't Also, you're onclick has a second equals sign which may be throwing things out...

Try:

document.write("&nbsp;<a href='http://www.linkedpage.htm' target='\gf' onClick='fgf = window.open(\'\',\'gf\');fgf.focus()'>

Also, what error are you getting?

Have you closed your document.write?

kaled

9:49 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tag attributes MUST BE IN DOUBLE QUOTES if they contain spaces or some other special chars such as =<>. Fix that and report back if you still can't get it to work.

Remember, if you use document.write() to write data that contains double quotes, simple use single quotes to wrap the string and vice-versa.

e.g. document.write("Peter's party starts at 8 O' Clock"); is ok

but document.write('Peter's party starts at 8 O' Clock'); is garbage.

Kaled.

BlobFisk

10:25 am on Aug 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tag attributes MUST BE IN DOUBLE QUOTES if they contain spaces or some other special chars such as =<>.

I'm afraid that's not entirely true kaled. SGML (and hence HTML) specifies that attribute values can be in either double or single quotes. Both are equally valid and correct.

From: [w3.org ] :


By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa.

If you have an attribute value that contains a single quote then use a double quote and vice versa.

HTH