View Full Version : How do I parse this code?

10-04-2002, 01:33 PM
I need to edit the following code between the <tt> tag.

$_GetCode_='Your HTML code to get votes is:<BR><tt>&lt;A HREF="%%URLcode%%" TARGET="_BLANK"&gt;<BR>&lt;IMG SRC="%%URLvote%%" BORDER="0"&gt;&lt;/A&gt;</tt>';

This is the code I'd like to replace it with -

<a href="%%URLvote%%" target="MyWindow" onClick="w=650;h=480;posx = (screen.availWidth/2)-(w/2);posy = (screen.availHeight/2)-(h/2);win = window.open(this.href,this. target,'location=0,toolbar=0,resizable=1,scrollbars=1,width='+w+',height='+h+',left='+posx+',top='+p osy+',screenX='+posx+',screenY='+posy); win.focus(); return false;"><IMG SRC="%%URLvote%%" BORDER="0"></a>

Please note after the $_GetCode_= is a ' . This is causing problems with the javascripting that I wish to add. Is there a solution? I have tried replacing them with \ ' but that did'nt seem to work. Unless I did it wrong!

10-04-2002, 03:15 PM
$_GetCode_ = '<a href="%%URLvote%%" target="MyWindow" onClick="w=650;h=480;posx = (screen.availWidth/2)-(w/2);posy = (screen.availHeight/2)-(h/2);win = window.open(this.href,this. target,\\'location=0,toolbar=0,resizable=1,scrollbars=1,width=\\'+w+\\',height=\\'+h+\\',left=\\'+po sx+\\',top=\\'+posy+\\',screenX=\\'+posx+\\',screenY=\\'+posy); win.focus(); return false;"><IMG SRC="%%URLvote%%" BORDER="0"></a>';

echo $_GetCode_;

works for me. Watch out, this forum eats backslashes and inserts occasional line breaks/space that shouldn't be there. But you get the idea, I just did an replace of all single quotes to escape them with the backslash. It really does work.

If it's still not working for you, then there must be another cause for the errors you get.