Iframe Block Alternative

Permalink
I have a client that would like to take "tickers" fromhttp://www.kitco.com and insert them on the sidebar of their website.

And example of what I tried to do is create a new HTML block and add:

<style media="screen" type="text/css">

#outerdiv
{
width:184px;
height:200px;
overflow:hidden;
position:relative;
}

#innerIframe
{
position:absolute;
top:-403px;
left:-2px;
width: 184px;
height: 580px;
}
</style>


<div id='outerdiv'>
<iframe src="http://www.kitco.com/" id='innerIframe' scrolling=no></iframe>
</div>

This is one of the tickers that my client would like and it shows up just fine in an editor but as soon as I put it into a block on the Concrete5 website the page redirects tohttp://www.kitco.com/

How can I get this ticker to show up without redirecting the entire page to the link in the iframe? I tried downloading two different add-ons for iFrames and they both acted the same as the HTML block with my code.

If anyone can shed some light on how to make this work that would be awesome!

 
JohntheFish replied on at Permalink Reply
JohntheFish
Never attempted what you are doing, so these are just idle thoughts...

Are you sure kitco.com is the ticker? not the main kitco entry page. I would expect an address designed for syndication to be more complex.

There is a trick with JavaScript to detect if your page is within a frame and jump out of it. Maybe that is what kitco is doing. Maybe it does that for sites that are not registered to frame it or do not provide a token.

You could experiment with an iframe to kitco on an html page outside of C5 and see what happens. Maybe try with script disabled in the browser.

You could also disable the inclusion of the iframe when in edit mode or when logged in, so you only render the kitco stuff for visitors. (on the chance that it is only the dashboard etc that it does not like)

You could also try using the developer console to trace what is triggering the redirect.

Are you sure kitco.com is the ticker? not the main kitco entry page. I would expect an address designed for syndication to be more complex.
bellairo replied on at Permalink Reply
JohntheFish I had absolutely no clue about that trick!

Surprisingly, when javascript is turned off in the browser then the iFrame shows up perfectly. I have contacted Kitco to request permission however in the mean time I still have an unsatisfied client. Do you know of any other tricks that might be able to disable javascript strictly in the iFrame? Even if there were a way to disable it for the individual page I have other elements on the page that depend on Javascript.

Any help or suggestions I am all ears!

and thanks in advance to the community and to JohntheFish :)
bellairo replied on at Permalink Reply
Ok, so after a bit of Googling and seeing everyone say this can't be done I found a glimpse of hope with:


$page = file_get_contents('URL HERE');// use CURL if possible

echo strip_javascript($page, 0);// 0 = allow no javascript

function strip_javascript($filter, $allowed=0){
if($allowed&1 == 0) // 1 href=...
$filter = preg_replace('/href=([\'"]).*?javascript:.*?\\1/i', "'", $filter);

if($allowed&2 == 0) // 2 <script....
$filter = preg_replace("/<script.*?>.*?<\/script>/i", "", $filter);

if($allowed&4 == 0) // 4 <tag on.... ---- useful for onlick or onload
$filter = preg_replace("/<(.*)?\son.+?=\s*?(['\"]).*?\\2/i", "<$1", $filter);
return $filter;
}

Also there was mention of using a:

docShell interface:
nodeIframe.docShell.allowJavascript = false;

Do you think this will work?

If so can I get some help with the PHP because as a Graphic Designer I dable in HTML, CSS and Javascript but when I look at PHP its like a white guy that had that spanish class in high school and knows a few words but not enough to comfortably talk to somebody from Mexico (or Spain) in spanish.

If not... Any other suggestions!?
JohntheFish replied on at Permalink Reply
JohntheFish
It could work, but it is a convoluted way of doing it and is based on getting a temporary copy of the kitco page onto your server, modifying it to strip script tags, then serving it into the iframe. As such:

- It will be slow, because the page goes through 2 jumps before being displayed (you would need to add caching).
- If Kitco blocks framing, there is a good chance it also block serving assets to pages other than its own . (ie, you could go through all the work only to find that css, images etc are withheld)
- Kitco may depend on script for the functionality you want, in which case even if all the rest works, it could still be no use to your customer.

I am afraid the best answer is to discuss with Kitco a way to get their content into your iframe with their cooperation.

If they Don't want you to show their content, you don't have much of a chance without lots of work to get it (and it could still be in breach of copyright). If they do want you to show their content, they can provide a way round this issue.
JohntheFish replied on at Permalink Reply
JohntheFish
Before going too far down this avenue, did you try the other experiments I suggested above?

Have you confirmed it is script jumping out of the frame and not some other script related cause?