Hmm, so I have code that loads an iframe on a page called page2.html. The iframe currently loads the homepage of the site (http://mydomain.com). However, what I would like to do is place any page requested in an iframe as well.
So, like: http://mydomain.com/mypage/mysubpage
This needs to be grabbed from javascript/jquery and handed down into the iframe src value. This sounds easy enough, however, their is a global.js file that is redirecting to another page (page2.html) which than outputs the iframe (loading http://mydomain.com), so I'll need to pass a variable via javascript from the global.js function and put it into the page2.html page somehow to tell it to load the iframe for a different url instead of http://mydomain.com.
What's the best way to do this exactly? So, if you go here: http://cdficonnect.org in your desktop pc, you will notice that it loads the page in the iframe, but if you go here: http://www.cdficonnect.org/#/pages/articles/317 it still loads up the main page into the iframe and not that url. How to tell it to load up that url and not the main page?
Sounds simple enough, but having problems with implementing it.
Cookie Approach here:
In the redirector script, before it redirects...
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) +
((exdays==null) ? "" : ("; expires="+exdate.toUTCString()));
document.cookie=c_name + "=" + c_value + ";domain=cdficonnect.org";
}
setCookie('curURL', document.URL, 0);
In desktop.html, within the head:
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
var curURL = getCookie('curURL');
$('iframe').attr('src', curURL);
This always displays the homepage within the iframe no matter what url I put into the address: http://cdficonnect.org
cdiconnect.com, and trying to read it inwww.cdiconnect.com. SincesetCookiedoesn't specify that the cookie should be available in subdomains, it can't read it. Try addingdomain=cdiconnect.com;to the cookie.