Javascript 如何使驱动器API WebViewLink URL可单击?
当它显示时: 如何使URL可点击 另外,如何加粗file.name并更改文本的颜色?编辑 @Pig正确地指出,您可以将内容放入Javascript 如何使驱动器API WebViewLink URL可单击?,javascript,Javascript,当它显示时: 如何使URL可点击 另外,如何加粗file.name并更改文本的颜色?编辑 @Pig正确地指出,您可以将内容放入 appendPre(file.name + ' (' + file.viewedByMeTime + ')'+ ' (' + file.webViewLink + ')' +' (' + file.quotaBytesUsed + ' bytes)'); 这增加了一个 function appendLink(url) { // create a DOM no
appendPre(file.name + ' (' + file.viewedByMeTime + ')'+ ' (' + file.webViewLink + ')' +' (' + file.quotaBytesUsed + ' bytes)');
这增加了一个
function appendLink(url) {
// create a DOM node, an <a> tag.
var link = document.createElement('a');
// a "text node" is what lives inside the tag <a>text node</a>
var _text = document.createTextNode("click me");
// add that text node to the link, so now we have: <a> click me </a>
link.appendChild(_text);
// set the actual link in the href attribute
link.href = url;
// add a CSS class so we can control the style of text easily
link.classList.add('drive-link');
// add this link somewhere in your document
doucment.getElementById('links').appendChild(link);
}
(顺便说一句,你应该标记正确!)它是可点击的,但它不会链接你的url。我的意思是,你可以随意点击,但什么都不会发生。还有“山姆斧头瘸子”。不是建设性的——您可以说“标记仅用于文本,不能包含链接,您应该发布更多代码”。“学习HTML和Javascript”,虽然可能是一个很好的参考,但几乎没有解决具体的问题,而且有点屈尊俯就。我被纠正了。我从来没有在标记中看到过这样的标记,事实上,我不知道你会怎么做。如果您只是将字符串“”附加到中,它将只显示这些字符,而不是呈现链接。您必须使用“&zwj;”和其他巫毒来实现这一点,因此,如果预格式化文本不是您的目标,那么使用标记以外的内容可能是更好的做法。嘿,谢谢@jdbochem,因此我使用的函数是来自的示例listFile函数,但做了一些更改。如何将您的函数代码应用于我的函数代码?另外,我只希望file.webViewLink是一个可点击的URL,没有其他内容。@jgbochem,而且,如果可能的话,我希望所有内容都在同一行中。最后,我是否触发它:appendLink(file.webView)?
function appendLink(url) {
// create a DOM node, an <a> tag.
var link = document.createElement('a');
// a "text node" is what lives inside the tag <a>text node</a>
var _text = document.createTextNode("click me");
// add that text node to the link, so now we have: <a> click me </a>
link.appendChild(_text);
// set the actual link in the href attribute
link.href = url;
// add a CSS class so we can control the style of text easily
link.classList.add('drive-link');
// add this link somewhere in your document
doucment.getElementById('links').appendChild(link);
}
.drive-link {font-weight: bold; color: peachpuff;}