无法在 JavaScript 字符串中工作

发布于 2024-10-17 01:39:39 字数 1168 浏览 1 评论 0原文

好的,我的网站有一个基于 javascript 的 Twitter 插件。

的 innerHTML 打印出“推文内容”

我使用 Jquery ajax 获取 JSON,然后使用我网站上标签

...一切正常,但我想制作所有主题标签和 @ 链接。我这样设置的方式似乎是有效的,但由于某种原因,CSS 样式表会对链接进行样式设置,但是浏览器不会将链接视为链接。

var dynamicString = data[0].text;
var dispString = "";
while(dynamicString.indexOf("#") != -1)
{
  var indexOfHash = 0;
  var indexOfSpace =0;
  var indexOfHash = dynamicString.indexOf("#");
  dispString += dynamicString.slice(0, indexOfHash);
  dynamicString = dynamicString.slice(indexOfHash, dynamicString.length);                                   
  indexOfSpace = dynamicString.indexOf(" ");
  dispString += "<a class='twitterlink' href='http://twitter.com/#!/search/%23";
  dispString += dynamicString.slice(1, indexOfSpace);
  dispString += "'>" + dynamicString.slice(0, indexOfSpace) + "</a>";
  dynamicString = dynamicString.slice(indexOfSpace, dynamicString.length);
}

dispString += dynamicString;

var twitterPTag = document.getElementById('lasttweet');
twitterPTag.innerHTML = "<span id='tweettitle'>Latest Tweet:</span><br />" + dispString;

我的网站是 justinmburrous.com,查看该脚本正在运行的任何页面。

Okay I have a javascript based twitter plugin for my my website.

I use Jquery ajax to get the JSON, and I then print out the "tweeted content" with the innerHTML of a

tag on my site...

That all works fine, however I wanted to make all of the hashtags and @ links. They way I have this set up is seems to be working, but for some reason the css style sheets will style the link, however the borwser does not treat the links as links.

var dynamicString = data[0].text;
var dispString = "";
while(dynamicString.indexOf("#") != -1)
{
  var indexOfHash = 0;
  var indexOfSpace =0;
  var indexOfHash = dynamicString.indexOf("#");
  dispString += dynamicString.slice(0, indexOfHash);
  dynamicString = dynamicString.slice(indexOfHash, dynamicString.length);                                   
  indexOfSpace = dynamicString.indexOf(" ");
  dispString += "<a class='twitterlink' href='http://twitter.com/#!/search/%23";
  dispString += dynamicString.slice(1, indexOfSpace);
  dispString += "'>" + dynamicString.slice(0, indexOfSpace) + "</a>";
  dynamicString = dynamicString.slice(indexOfSpace, dynamicString.length);
}

dispString += dynamicString;

var twitterPTag = document.getElementById('lasttweet');
twitterPTag.innerHTML = "<span id='tweettitle'>Latest Tweet:</span><br />" + dispString;

My website is justinmburrous.com, check out any page for this script working, live.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角迷惘 2024-10-24 01:39:39

更改

h2.subpageheader {
    color: black;
    left: 50%;
    margin-left: -350px;
    position: absolute;
    text-align: left;
    top: 81px;
    width: 900px;
    z-index: 3;
}

它太宽且 z-index 高于链接

Change

h2.subpageheader {
    color: black;
    left: 50%;
    margin-left: -350px;
    position: absolute;
    text-align: left;
    top: 81px;
    width: 900px;
    z-index: 3;
}

it is too wide and the z-index higher than the link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文