开发者

Blinking page title

I'm trying to get some notifications working for AJAXChat. To do this all I want to do is get the title of the page to blink until focused. To do this I'm using the jquery-titlealert plugin. The problem is the html that is generated for the onload event is generated inside a js file shown here

return  '<d开发者_运维问答iv id="'
            + this.getMessageDocumentID(messageID)
            + '" class="'
            + rowClass
            + '">'
            + this.getDeletionLink(messageID, userID, userRole, channelID)
            + dateTime
            + '<span class="'
            + userClass
            + '"'
            + this.getChatListUserNameTitle(userID, userName, userRole, ip)
            + ' dir="'
            + this.baseDirection
            + '" onload="$.titleAlert('New Message');">'
            + userName
            + '</span>'
            + colon
            + this.replaceText(messageText)
            + '</div>';
    return

When I use this, it breaks the page. If I replace ('New Message') with (New Message) the page loads again but the notification isn't working. I think this is because its displaying a Javascript function inside Javascript. Anyone see anything here I'm missing?


Have you tried escaping your quotes? I.e.:

+ '" onload="$.titleAlert(\'New Message\');">' 

Any single quote (') inside a single quoted string (or double quote (") inside a double quoted string) needs a backslash (\) before it. See the MDN String Literals documentation for more information about strings and proper character escaping.


You need to escape the quotes. Change this

'" onload="$.titleAlert('New Message');">'

to this

'" onload="$.titleAlert(\'New Message\');">' 


Try escaping the apostraphe's correctly:

+ '" onload="$.titleAlert(\'New Message\');">'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜