When content is duplicate / similar the canonical link will point the bot at the page you would prefer as the authoritative page. Any page which you do not help persuade the choice, the bot will decide (and consider one of them as duplication).
If the javascript points to a new page you probably want the canonical link pointing to the same page otherwise google may well consider it cloaking.
Similarity is based on content (text) not url name nor page layout.
|