Hey!
First of all I want to say that I am not JS programmer, so my code style or some methods using could be urgly :)
So, I just found the way how to do this :)
In Freecause(http://freecause.com) we needed to make a forum with cross-social networks support ability.
We decided to make it based on iframes, cause then it'll be simplier to implement :)
While developing we got one prob.. the auto-height of iframe,... When you have all files on one domain - its not a prob,..
but if files are from different domain - then you get cross-domain security problems.
There is one method that works ok. Its needed to use few iframes (3 frames from main domain and 1 from the domain of your app).
But Facebook has its own libs for implementing this(check docs here: http://wiki.developers.facebook.com/index.php/Resizable_IFrame) and it was very useful to run auto-height iframes for facebook applications(check it on PinkRibbon application here: http://apps.facebook.com/pinkribbon/ - Discussion tab).
As all know Myspace API and myspace apps are not the same as in Facebook. Myspace uses v0.7 of Google Opensocial. And as its Google gadget technology - all is based on JS reloads of the pages.
So You cant just write http://some.myspace.app.com/some_file.html for Myspace. All page reloads are being done throught makerequest JS function.
Another method is to use iframes. BUT, there is one problem - there is no special API for resizing your iframes. And of course cross-domain policy of javascript doesnt allow you to use the 4-frames auto-height :)
In Myspace forums its possible to find a lot of questions on this. There is one method to use makerequest and proxy your page throught myspace,.. but only once..
So, we found the method to make resizable iframe applications for Myspace.
You can check its working on PinkRibbon Myspace application - Discussion tab(add it from here: http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=417866306)
Ok,.. so returning to main stuff - method to resize iframes in myspace applications.
I'll try to explain it based on example.
You'll be needed to have one conf for your myspace app. And also 2 files on any host for proxiing (I think they should be from same host, but its connected with myspace proxy and opensocial keys, so I can be wrong).
Lets call them "srv_receiver.htm" and "frame.html".
So, first of all - you're needed to have this myspace app source:
<div id="app_body" style="display: none;">In few words, we're loading the "frame.html" page which allows us to hide hash params that are sent from your real app (real height).
<iframe id="ifframe" name="ifframe" width="646" resizable="true" frameborder="0" scrolling="no" allowtransparency="true" style="border: none; background:transparent;"></iframe>
</div>
<script type="text/javascript">
os = opensocial.Container.get();
dataReqObj = os.newDataRequest();
var viewerReq = os.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER);
dataReqObj.add(viewerReq, 'viewer');
dataReqObj.send(viewerResponse);
function viewerResponse(data) {
var viewer = data.get('viewer').getData();
var userID = viewer.getId();
var app_id = myOpenSocialAppOpts.ID;
var check_url = "http://yourhost.com/pathto/frame.html";
opensocial.Container.get().makeRequest( check_url,
function(content, url, error)
{
//loading your app into "ifframe" iframe and sending some params if needed
document.getElementById("ifframe").src = url+"#init;someparam=somevalue&someparam2=somevalue2;
});
document.getElementById("app_body").style.display = "block";
var height = document.getElementById("app_body").offsetHeight + 100;
if (500 > height) {
height = 500;
}
opensocial.Container.get().resizePanel(height);
//initial height setting
var height=500;
function checkForMessages(){
try{
//if height is not changed - do nothing
if(ifframe.data != height){
//getting the real height from your application
height = ifframe.data;
//and if its less then minimal height - set height to minimal height. I used 500 for example.
if(height<500){
height = 500;
}
document.getElementById("ifframe").height = height;
//after setting the right height for our main iframe, we're fixing the canvas height by MySpace API command :)
opensocial.Container.get().resizePanel(height);
}
}
catch(e){}
}
//We're trying to check height change every 200 msecs
setInterval(checkForMessages, 200);
}
</script>
"frame.html" enables communicating between your main app frame and you real app (throught additional "srv_receiver.html"). "init" in "ifframe" source path is just a hash param that says to frame.html to make some action.
In this case it just loads your app.
So,.. "frame.html" now :
<html>This was your main communication file which was proxied throught myspace via makerequest, so it should have no probs with cross-domain security.
<head>
<title>test</title>
</head>
<body>
<div id="mydiv2"></div>
<iframe id="fframe" name="fframe" width="646" resizable="true" frameborder="0" scrolling="no" allowtransparency="true" style="border: none; background:transparent;"></iframe>
<script type="text/javascript">
var data ="";
var b = "";
var temp = new Array();
function checkForMessages(){
//checking if hash param is changed
if (location.hash != b){
b = location.hash;
temp = new Array();
//splitting command (like "init") and data
temp = decodeURIComponent(location.hash.substring(1)).split(';');
if(temp[0] == 'init'){
//executing init command
var loc = location.search;
//getting opensocial key for correct loading of the last file we're needed to use in our app ("srv_receiver.htm")
var re = /opensocial_token=(.*?)\&/;
loc.match(re);
var session2 = RegExp.$1;
//setting needed params for your application + getting them from string that was sent from init command
temp[1] = temp[1] + '&opensocial_token='+session2;
document.getElementById('fframe').src='http://yourhost.com/some.cgi?'+temp[1];
}
else if(temp[0] == 'change_height'){
//executing resizing from params sent from your application throught "srv_receiver.htm"
// + checking if height of your app is changed
if(temp[1] != data){
data = temp[1];
ReceiveDataFromCl(data);
}
}
}
}
//this function resizes the height of "fframe" - iframe of your real application
function ReceiveDataFromCl(data){
if (data<500){
document.getElementById("fframe").height = 500;
}
else{
document.getElementById("fframe").height = data;
}
}
//checking for command every 200 msecs
setInterval(checkForMessages, 200);
</script>
</body>
</html>
I hope I commented the code right, so you should have no probs with applying it for your application.
And the last one file - "srv_receiver.htm":
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"This file should be used as is, as its working with your "frame.html" domain :)
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>cross domain receiver page</title>
<script type="text/javascript">
function load() {
data = window.location.hash;
document.write(data);
var href = window.parent.parent.location.href;
href = href.replace(/#.*$/,'');
window.parent.parent.location =href+data;
}
</script>
</head>
<body onload="load()">
</body>
</html>
The main stuff you should do in your app is something like this:
<div id="mydiv" style="visibility:hidden"></div>I used jquery for getting the real height of the application.
<script type="text/javascript">
if(self != top){
var actualHeight = "";
//set here the right path to your "srv_receiver.htm" (in the end of line) and opensocial token from frame.html (sent as param)
var par = 'http://api.msappspace.com/proxy/relay.proxy?opensocial_token=OPENSOCIAL_TOKEN_HERE&opensocial_url=http%3A//yourhost.com/pathto/srv_receiver.htm';
//jquery stuff that runs in the end of loading of the page
$(window).load(function(){
//creating the hidden iframe for communication
var iframe = document.createElement('iframe');
iframe.setAttribute('src', par);
iframe.setAttribute('id', 'iframe4');
iframe.setAttribute('name', 'iframe4');
document.getElementById("mydiv").appendChild(iframe);
//getting height of your app
actualHeight = $('body').height();
//sending height to main window throught the "frame.html"
SendDataToSrv('change_height;'+actualHeight);
});
//function that does communication
function SendDataToSrv(data){
document.getElementById('iframe4').src = par+"#"+data;
}
}
Of course you can use any other method.
Maybe I needed to make all more detaily explained, but I did as I could in 5 a.m. ;)
If I explained all correctly and you understand all - you should have no probs with resizing of iframes for your applications in myspace :)
15 comments:
Nick,
I can't get it working.
Which file should be my External IFrame Url? (http://.../osConf.xml)
Tony
The structure is (each inside other):
your canvas page -> frame.html* -> Your Iframe App -> srv_receiver.htm*
* - means loading via proxying by make_request/myspace proxy
Hi Nick,
Need your kind help.
I made an application which is running on our server. Now I adding this in Myspace app. For doing this I have chosen external iframe provided by Myspace developer account and given my application url as asked me. Now I picked up all the file paths to access the javascript libraries from PinkRibbon app.
And I'm calling the function opensocial.Container.get().resizePanel();
from the footer of my page when entire content has been prepared to load. But I'm not able to get height according to the page content.
In addition I'm also not able to understand where should I put these files frame.html, srv_receiver.html and other code given below these if I try with this solution.
Please do reply me soon.
Thanks,
Ashwani
As I reponded in previous comment.. You should load special frame.html (described in article) by makerequest of myspace.
Then inside this frame you load your real page (like forum in pinkribbon) from your site directly.
And you send a key for makerequest there by JS call.
And then, inside your real page - you do load of srv_receiver.htm by emulating makerequest with same key as you did for frame.html.
Then you have communications between all frames and can do resizing by command from Your Iframe App.
Hey,
If you want you can try to get in contact by email: dnikolayev AT gmail, I'll try to help
[url=http://community.bsu.edu/members/buy+online+Viagra.aspx]canadian pharmacy Viagra[/url]
[url=http://ceklansi.ru/index.php]знакомства литва[/url]
[url=http://ceklansi.ru/tegos-ru-znakomstva.php]тегос ру знакомства[/url]
[url=http://ceklansi.ru/olga-blyad.php]ольга блядь[/url]
[url=http://ceklansi.ru/odinokaya-zhenschina-zhelaet-poznakomitsya-onlayn.php]одинокая женщина желает познакомиться онлайн[/url]
[url=http://ceklansi.ru/blyadi-luganska.php]бляди луганска[/url]
[url=http://celuyou.ru/gde-snyat-molodye-prostitutku.php]где снять молодые проститутку[/url]
[url=http://celuyou.ru/chat-intimnyh-znakomstv.php]чат интимных знакомств[/url]
[url=http://celuyou.ru/avtozavodskaya-intim.php]автозаводская интим[/url]
[url=http://celuyou.ru/serpuhovsko-timiryazevskaya-prostitutki.php]серпуховско-тимирязевская проститутки[/url]
[url=http://celuyou.ru/znakomstva-bez.php]знакомства без[/url]
[url=http://deperovero.ru/poznakomlus-s-armyankoy.php]познакомлюсь с армянкой[/url]
[url=http://deperovero.ru/botanicheskiy-sad-intim.php]ботанический сад интим[/url][url=http://mx.deperovero.ru/index.php]донецк знакомства секс[/url]
[url=http://mx.deperovero.ru/prostitutki-strogino.php]проститутки строгино[/url]
[url=http://rp.deperovero.ru/deshevye-shluhi-moskvy-vyezd.php]дешевые шлюхи москвы выезд[/url]
[url=http://rp.deperovero.ru/intim-internet-znakomstva.php]интим интернет знакомства[/url]
[url=http://ss.deperovero.ru/poznakomitsya-s-tatarkoy.php]познакомиться с татаркой[/url]
[url=http://ss.deperovero.ru/znakomstva-sochi.php]знакомства сочи[/url]
[url=http://tt.deperovero.ru/sluzhba-znakomstv-muzhchina-i-zhenschina.php]служба знакомств мужчина и женщина[/url]
[url=http://tt.deperovero.ru/intim-belorussii.php]интим белоруссии[/url]
www.BedroomBox.co.uk
SEX TOYS and LINGERIE at UKs Official Sex Store!
http://www.xbox360achievements.org/forum/member.php?u=262795 zyprexa litigants class action lawsuit jack b weinstein zyprexa lawsuit claims chicago zyprexa lawyer http://www.xbox360achievements.org/forum/member.php?u=262784 buy zyprexa cheap zyprexa wine lamictal interactions zyprexa attorney ohio http://www.xbox360achievements.org/forum/member.php?u=262788 march 2009 info on zyprexa lawsuit olanzapine zyprexa zyprexa and elderly dosing http://www.xbox360achievements.org/forum/member.php?u=262777 zyprexa attorneys los angeles zyprexa and alzheimers zyprexa daily telegraph http://www.xbox360achievements.org/forum/member.php?u=262779 hyperglycemia zyprexa salt lake city zyprexa attorneys zyprexa attorney ohio http://www.xbox360achievements.org/forum/member.php?u=262787 zyprexa law suit zyprexa recall southern california zyprexa 5mg http://www.xbox360achievements.org/forum/member.php?u=262787 zyprexa and alzheimers hartford zyprexa lawyer mr ernest j blansfield lawsuit zyprexa http://www.xbox360achievements.org/forum/member.php?u=262789 buy zyprexa without prescription zyprexa en espa ol zyprexa lawyer columbus http://www.xbox360achievements.org/forum/member.php?u=262792 zyprexa toxicity zyprexa diabetes law firm zyprexa side effect http://www.xbox360achievements.org/forum/member.php?u=262789 zyprexa manufacturer zyprexa lawyers australia class action zyprexa eating disorders
http://www.xbox360achievements.org/forum/member.php?u=273705 zyprexa olanzapine tablets zyprexa medication zyprexa patient info http://www.xbox360achievements.org/forum/member.php?u=273719 zyprexa 5 mg comparison drugs zyprexa cognitive thinking zyprexa effectivness http://www.xbox360achievements.org/forum/member.php?u=273719 zyprexa law sute zyprexa lawyers california zyprexa doseage information http://www.xbox360achievements.org/forum/member.php?u=273702 zyprexa urinary incontinence physicians desk reference zyprexa olanzapine zyprexa side effects http://www.xbox360achievements.org/forum/member.php?u=273719 zyprexa sex hormones generic zyprexa zyprexa nytimes http://www.xbox360achievements.org/forum/member.php?u=273694 quitting zyprexa vomiting anxiety lawyer zyprexa eli lilly july 2009 zyprexa and mr ernest j blansfield http://www.xbox360achievements.org/forum/member.php?u=273702 physicians desk reference zyprexa eli lilly zyprexa possible side effects of zyprexa http://www.xbox360achievements.org/forum/member.php?u=273717 zyprexa vertigo buy zyprexa cheap zyprexa withdrawal vomiting http://www.xbox360achievements.org/forum/member.php?u=273710 hartford zyprexa lawyers zyprexa generic version zyprexa recall san diego http://www.xbox360achievements.org/forum/member.php?u=273719 zyprexa australia zyprexa effect zyprexa 5 mg
Buy Endress & Hauser models at up to 20% discount from list price
Endress+Hauser is a leading supplier of measuring instruments and automation solutions for the industrial process engineering industry.
Endress+Hauser is recognized as a leading supplier of industrial measurement and automation equipment, providing services and solutions for industrial processes all over the world. Endress+Hauser offer comprehensive process solutions for flow, level, pressure, analysis, temperature, recording and digital communications across a wide range of industries, optimizing processes in regards to economic efficiency, safety and environmental protection.
As major stockists of many Endress and Hauser level instruments, We [url=http://www.endress.org.ua]official distributor Endress+Hauser in Ukraine[/url], can offer a range of Endress & Hauser models at up to 20% discount from list price - prices usually only available when buying in bulk.
Feel free to contact us.
Hello! Can you tell me how i can register mail at google [url=http://google.com]google[/url] http://google.com
how does carbon dating work [url=http://loveepicentre.com/]gay personals[/url] christian dating services http://loveepicentre.com/ danish dating sites
sugar daddy dating [url=http://loveepicentre.com/]gay personals state college pa[/url] exclusivity dating http://loveepicentre.com/ amaeuteur dating
Find a Dell Laptop Battery [url=http://www.hqlaptopbatteries.com/-4101wlm-laptopbatterymodel1417.html]laptop batteries for notebook computers[/url] Fujitsu Laptop http://www.hqlaptopbatteries.com/battery-5502wlmi-batterytype1.html Discount Laptop Batteries
hp laptop batteries [url=http://www.hqlaptopbatteries.com/-d520-laptopbatterymodel787.html]Compaq laptop battery[/url] laptop price http://www.hqlaptopbatteries.com/-4104-laptopbatterymodel1419.html compare laptop prices
laptop battery [url=http://www.hqlaptopbatteries.com/page134.html]AC Adapter[/url] Laptop AC Adapter http://www.hqlaptopbatteries.com/page78.html laptop comparison
Hello! Can you tell me how i can register mail at google [url=http://google.com]google[/url] http://google.com
Post a Comment