Javascript is driving me mad... - Posted (1290 Views)
Retired Support Moderator
MarcelG
Posts: 2625
2625
Here's one I've been working on for over 2 hours now. Watch this in FireFox : http://www.scoutingkeentmoesel.nl/shortnews.asp?link_id=2689
You'll see a dutch topic, with a video in it. (It's my Scouting site)

Well, open the same page with IE. A Javascript error, and no video. dead The Javascript error is non-existent in FireFox, and in IE the linenumber it refers to has no relation with javascript...
I've found out that deleting the ' in the topic message (in the part 'n onverlaat) 'fixes' it in IE....but why??!
Can anyone help me with finding out which piece of javascript goes wrong?<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Average Member
phy1729
Posts: 589
589
try a \'<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
Strangely, that works, but I also simply see a \' question It's as if the topic-content is parsed through a javascript function somewhere...but where ? I've updated the post, so now you can see the video... http://www.scoutingkeentmoesel.nl/shortnews.asp?link_id=2689<
Posted
Average Member
phy1729
Posts: 589
589
I think you're using the string in two diffrent places one doesn't need to be jsescaped namely the one you're seeing and the other does somewhere contained by single quotes. You should use chkString(var,"jsurlpath") on te second instance.<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
It's getting stranger and stranger. It seems it only fails when the following combination of characters exists in the topic, áfter the youtube video javascript call: [space][singlequote]. So, " '" breaks it, but " [b][/b]'" doesn't brake it. The first "Hier 'n nieuw" doesn't brake it, and neither does the "foto's" part.
I've quadruple checked the source, and I cannot find any javascript call that is using the topic-content.
Code:
<font color="" face="Tahoma, Arial, Sans Serif" size="2"><span class="spnMessageText" id="msg">
Hier 'n nieuw filmpje van ons supervlot, tijdens de vlottenrace van de Regio Weert,
op vrijdagavond 23 mei jonstleden. <img src="images/PDT_Yellow_Sheika_03.gif" border="0"
alt="" title="" ALIGN=ABSBOTTOM /><br />
<div class="tube">
<script language="javascript">EmbedYT("http://www.youtube.com/v/m5u6vUKf8KY",375,298,"false","high","white","white")
</script>
</div><div class="break">
</div>
<br />Voor de foto's <a href="http://www.scoutbytes.com/gallery/vrexprw08/index.html" target="_blank">klik hier</a>. <br /><table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000">
<tr><td width="100%" bgcolor="#000000"><font color="beige"><span class="size1">
Het vorige bericht over de vlottenrace is door 'n onverlaat verwijderd, inclusief alle reacties. </span class="size1"></font id="beige"></td></tr>
</table>
</div></span id="msg">
I do see I'm not closing the font tag....I'll check if that makes any difference.<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
I think I've found it ; I also parsed the topic content into the HTML keywords section....when I removed that part, the code worked, and the javascript error disappeared. question<
Posted
Average Member
phy1729
Posts: 589
589
Possibly running code found from this blog / project before using it js side would remove the issue.
Code:

function addslashes( str ) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Ates Goral (http://magnetiq.com)
// + improved by: marrtins
// * example 1: addslashes("kevin's birthday");
// * returns 1: "kevin\'s birthday"

return str.replace('/(["\'\])/g', "\\$1").replace('/\0/g', "\\0");
}
<
 
You Must enter a message