tec-4 Posted October 28, 2011 Share Posted October 28, 2011 Hello Everyone, Have 2 links on a page that I am trying to manipulate to do the same thing (add a bookmark to a database). The first link below works fine and adds the bookmark if it is not currently in the DB and notifies you if it is in the DB....the other one, with the slight modifications does not seem to do anything that I can notice and shows no response and does not add the bookmark to the DB...perhaps what I am trying to do is not valid JS.... What I have thus far: This one works: <a href="javascript:(function(){var jsScript=document.createElement('script'); jsScript.setAttribute('type','text/javascript'); jsScript.setAttribute('src', '/bookmark.php?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)); document.getElementsByTagName('head')[0].appendChild(jsScript); })();">Bookmark this!</a> This one does not work: -the only difference is that I replaced the "location.href" with an actual URL and the "document.title" with a title name. <a href="javascript:(function(){var jsScript=document.createElement('script'); jsScript.setAttribute('type','text/javascript'); jsScript.setAttribute('src', '/bookmark.php?url='+encodeURIComponent(http://example.com)+'&title='+encodeURIComponent(Add Me)); document.getElementsByTagName('head')[0].appendChild(jsScript); })();">TEST ME - Bookmark this!</a> I also tried it without the encodeURIComponent and still did not seen to take. Is what I'm trying to do not valid? Essentially trying to make it so that I can place more than one of these links on a page and bookmark a specific item and not the actual page that I am currently viewing. Quote Link to comment Share on other sites More sharing options...
Adam Posted October 28, 2011 Share Posted October 28, 2011 You need quotes around "http://example.com" and "Add Me". Quote Link to comment Share on other sites More sharing options...
tec-4 Posted October 28, 2011 Author Share Posted October 28, 2011 Gotcha. Didn't seem to work with the double quotes, tried escaping them w/ still no luck but when I put them in single quotes it seemed to do the trick. Thanks for the help Adam! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.