Javascript 如何在firefox文本框中链接URL
Heloo我有这个代码给我一个当前的url和标题。如果我单击按钮,它将显示Javascript 如何在firefox文本框中链接URL,javascript,firefox,Javascript,Firefox,Heloo我有这个代码给我一个当前的url和标题。如果我单击按钮,它将显示 我怎样才能只获得标题作为链接 // Show Current Open URL function CurrentOpenURL() { // clears the field of textbox when clicked other button document.getElementById('MyExtension').value=''; var textbox =
我怎样才能只获得标题作为链接
// Show Current Open URL
function CurrentOpenURL()
{
// clears the field of textbox when clicked other button
document.getElementById('MyExtension').value='';
var textbox = document.getElementById("MyExtension");
var title = getBrowser().contentTitle ;
var url = getBrowser().currentURI.spec;
textbox.value = title.link(url);
使用此正则表达式,您将替换html标记
var title = url.replace(/(<([^>]+)>)/ig,"");
var title=url.replace(/(]+)>)/ig,”;
您不需要jQuery来完成此操作。您有:textbox.value=title.link(url);您不想要:textbox.value=title;是的,但它不可点击:(它唯一的文本等待,让我确保我做对了,你想让一个文本框像一个标签一样可点击吗?是的?我只想把这个标题作为指向当前URL的链接,然后你需要用javascript或Jquery添加一个onclick操作:document.getElementById(“MyExtension”).setAttribute('onclick','window.location(“+url+”);没什么变化..还有a href和它不可点击吗:(但是谢谢你帮我