使用colorbox加载外部URL然后截断

时间:2011-10-23 14:54:39

标签: javascript jquery html colorbox

我一直在争论这一段时间,所以我希望我能在这里找到解决方案。

我希望在彩盒弹出窗口中打开外部网址到iframe。这一切都很好。我只想运行一个post post加载的函数来摆脱我不需要的任何内容(例如标题和正文标记)。以下是我到目前为止的情况:

$('a[href*="/return-policy"]').colorbox({
        href: "/return-policy?language=" + lang,
        width: "800px",
        height: "600px",
        scrolling: false,
        iframe: true
    });

这会返回:

<!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>title</title>
</head>

<body>
<div>load of crap I dont need</div>
    <div class="content-content colorbox-content" id="content-content">
    THE STUFF I NEED
    </div>
<div>load of crap I dont need</div>    
</body>
</html>

这是我所需要的(在colorbox-content中包括div colorbox-content):

<div class="content-content colorbox-content" id="content-content">
   THE STUFF I NEED
</div>

非常感谢任何帮助。

由于 ç

2 个答案:

答案 0 :(得分:4)

试试这个:

$('a[href*="/return-policy"]').colorbox({
        href: "/return-policy?language=" + lang + " #content-content",
        width: "800px",
        height: "600px",
        scrolling: false
    });

答案 1 :(得分:0)

var your_result=     $("div").append($("#content-content")).html()
相关问题