English 中文(简体)
利用高档,包括超
原标题:Using jQuery on a string containing HTML

我试图使一个领域与面板共用箱相类似,你可以进入圆顶,并向你提供网页、标题、图片等数据。 我已经设立了一个服务器辅助服务,以便从该网页上接手,并试图获得页标题。 我试图这样做:

function getLinkData(link) {
  link =  /Home/GetStringFromURL?url=  + link;
  $.ajax({
    url: link,
    success: function (data) {
      $( #result ).html($(data).find( title ).html());
      $( #result ).fadeIn( slow );
    }
  });
}

which doesn t work, however the following does:

$(data).appendTo( #result )
var title = $( #result ).find( title ).html();
$( #result ).html(title);
$( #result ).fadeIn( slow );

but I don t want to write all the HTML to the page as in some case it redirects and does all sorts of nasty things. Any ideas? Thanks

页: 1

最佳回答

使用<条码>过滤<>/条码>而不是<条码>限制/编码>

$( #result ).html($(data).filter( title ).html());
问题回答

为达到这一目的,过滤器是你们需要的东西(正如你指出的:)。

$("#result").text($(data).filter("title").text());

However do not insert the HTML of the foreign document into your page. This will leave your site open to XSS attacks. As has been pointed out, this depends on the browser s innerHTML implementation, so it does not work consistently.

在服务器上进行所有相关的超文本处理甚至更好。 仅向您的书面陈述提供相关信息,将使客户代码vastly更加简单、快捷。 你们可以把安全/红衣帽子/肉类混为一谈,而不必担心危险地被送给你的使用者。 rel=“nofollow”>Your href=already has soft/

另一种办法是寻找标题。 幸运的是,与你自己提出的问题大不相同,认为标题非常容易,因为它的确如此;没有允许任何nes子。 看一下像<代码>和>; 标题和(......)”;/ 标题和“;,应当确定。

(如果是,我知道在html上从未使用过reg,但这是一个非常简单的情况)





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签