views:

172

answers:

1

Hi, im getting a javascript error when using coda slider in IE8:

"Expected ']'"

Weird thing is that it only triggers when only. If i use the localhost version of the site, nothing happens.

That line is when using:

echo '<a href="javascript:void(null);" onclick="$.prettyPhoto.open(
 [\''.implode('\',\'',$pp['gallery']['link']).'\'],
 [\''.implode('\',\'',$pp['gallery']['title']).'\'],
 [\''.implode('\',\'',$pp['gallery']['description']).'\']
);">gallery</a>';

any ideas?

+1  A: 

Hi,

Is one of your variables having a simple quote ?

Kaaviar
you saved my day. it seems someone already inserting news in the live site is using quotes and i'm not controlling it. thanks!
andufo
mmm im now converting simple quotes to ' but the javascript error remains :s if i delete the simple quotes, all problems dissapear. shouldn't it work when replacing the quotes?
andufo
`strInput.replace("'","\\'");`Note the double backslash. Because of your nesting, you may have to add additional layers of escaping -- just add another backslash until it works.
Andrew
thanks for the tip. i preferred to sanitize the string server side: $data = str_replace('\'','"',$data);return htmlspecialchars($data,ENT_QUOTES);
andufo