我正在尝试从另一个网站上的WordPress博客加载一个样式的RSS源,我可以加载它很好,但WordPress的安全性不允许你在一个框架中打开他们的网站。那么有人能告诉我如何更改样式化RSS源中链接的目标属性,这样他们就不会尝试在加载的框架中打开wordpress网站,而是改为使用新标签吗?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Load remote content into object element</title>
<style>
object {
height: 100%;
width: 100%;
}
html, body {
height: 100%;
overflow: hidden;
}
#content {
height: 99%;
overflow: hidden;
}
</style>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<div id="content"></div>
<script>
$("#content").html('<object data="articlefeed.html" />');
$("#content").find('a').attr("target", "_blank");
</script>
</body>
</html>
文章Feed:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
/* begin styles for RSS Feed */
.rss-box {
/* margin: 1em; */
width: 800px;
font-size: 16px;
background-color: #D6D9DC;
border: 0px solid #cc3300;
direction: ltr;
border-radius: 5px;
}
.rss-items {
margin-top:1px;
padding:0.5em; 0.5em;
/* margin-left:1px; */
color:#333;
direction: ltr;
}
p.rss-title {
padding:0.5em;
direction: ltr;
}
.rss-title {
text-decoration: none;
font-family: arial;
font-size: 85%;
background-color:#2e353d;
color:#f6f5f4;
font-weight:bold;
margin: 0px;
padding: 0em;
text-align: left;
direction: ltr;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.rss-item {
font-family: arial;
font-size: 85%;
font-weight : normal;
list-style:none;
padding-bottom:1em;
direction: ltr;
text-shadow: 0px 1px 0px #FFF;
}
.rss-item a {
text-decoration: underline;
color:#000000;
font-size: 105%;
font-weight:bold;
font-family:verdana;
direction: ltr;
line-height: 150%;
}
.rss-item a:visited {
color:#448822;
direction: ltr;
}
.rss-date {
font-size: 85%;
font-weight : normal;
color: #333;
direction: rtl;
}
.rss-item-auth {
}
</style>
</head>
<body>
<script language="JavaScript" src="http://www.feedroll.com/rssviewer/feed2js.php?src=http%3A%2F%2Fnyhederwp.oneclick.holdbarhest.dk%2Fcategory%2Fartikler%2Ffeed%2F&chan=y&num=5&desc=200&au=y&date=y&utf=y" charset="UTF-8" type="text/javascript"></script>
<noscript>
<a href="http://www.feedroll.com/rssviewer/feed2js.php?src=http%3A%2F%2Fnyhederwp.oneclick.holdbarhest.dk%2Fcategory%2Fartikler%2Ffeed%2F&chan=y&num=5&desc=200&au=y&date=y&utf=y&html=y">View RSS feed</a>
</noscript>
</body>
</html>
非常感谢帮助。
答案 0 :(得分:0)
您可以使用此结构:
$("#content a").attr('target','_blank');
答案 1 :(得分:0)