Forum Moderators: open
var url = window.location;
var title = document.title;
document.write ('<textarea cols=20 rows=3><a href="'+url+'" title="'+title+'">'+title+'</a></textarea>');
The problem is that the page titles are generated dynamically. They may occasionally have single or double quotes, or possibly other characters that would mess things up. Javascript seems to print them all inside the textarea okay, but obviously extra quotes would make the link fail when the text has been copied onto a webpage.
Is there a way around this, like some way to strip out specified characters from the page title?
Alternatively, and entirely unrelated to javascript, is it necessary for SE purposes to include the title attribute in the <a> tag, when it would be identical to the anchor text?