jquery - Javascript returning Uncaught TypeError: Cannot call method 'indexOf' of undefined -
i have facebook friend invite sender , following code returning , error.
iframehtml = $myjq('#polldaddy_embed_0').html(); if (iframehtml.indexof("facebook") === -1) { iframehtml = iframehtml.replace("fb_id=","fb_id="+window.uid); iframehtml = iframehtml.replace("?q_3826051_url=","&q_3826051_url="+encodeuricomponent(window.url)); $myjq('#polldaddy_embed_0').html(iframehtml); if (window.total>=5) { $myjq('#fb_first5_id').trigger('click'); } }
the error getting is:
uncaught typeerror: cannot call method 'indexof' of undefined
that tells element id
polldaddy_embed_0
didn't exist when code ran. if call $()
selector doesn't match anything, empty jquery set; if call html
on empty jquery set, undefined
, you're storing in iframehtml
variable. try call indexof
using variable, , error.
Comments
Post a Comment