简体   繁体   English

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

[英]Load external url with colorbox then truncate

I have been strugeling with this for a while now so I'm hopeing I can find a solution here. 我已经有一段时间了,所以我希望我能在这里找到解决方案。

I wish to open and external URL into an iframe in a colorbox popup. 我希望打开外部URL到colorbox弹出框中的iframe。 This is all working fine. 这一切都很好。 I just want to run a post loaded function that get rid of any content (such as header and body tags) that I dont need. 我只想运行一个post post加载的函数来摆脱我不需要的任何内容(例如标题和正文标记)。 Here is what I have so far: 这是我到目前为止:

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

This returns this: 这返回:

<!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>

This is all I require (in colorbox-content including the div colorbox-content ): 这就是我所需要的(在colorbox-content包括div colorbox-content ):

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

Any help with this is greatly appreciated. 非常感谢任何帮助。

Thanks C 谢谢C.

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM